Draw only left and top part of frame

Hi,

I draw four subplots that touch each other. Thus the “middle cross” of the frame is drawn twice and appears to be thicker then the “outer rectangle”. I came across an old post for an custom Axes that would allow to only draw part of the frame

http://www.mail-archive.com/matplotlib-users@…1838…urceforge.net/msg10242.html

However, when I run the example provided I get an “can’t set attribute error” (see traceback below). I use Python 2.7.1 |EPD 7.0-1 (32-bit) on Mac OS 10.5.8, which includes matplotlib version 1.0.1.

Is there a fix to get the custom class running again, or is there an alternative way to achieve what I intend?

Thanks a lot,

Markus

Traceback (most recent call last):
File “frametest.py”, line 165, in
ax = plt.subplot(sub, projection=‘frameaxes’)
File “/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/matplotlib/pyplot.py”, line 658, in subplot
a = fig.add_subplot(*args, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/matplotlib/figure.py”, line 687, in add_subplot
a = subplot_class_factory(projection_class)(self, *args, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/matplotlib/axes.py”, line 8380, in init
self._axes_class.init(self, fig, self.figbox, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/matplotlib/axes.py”, line 459, in init
self.cla()
File “frametest.py”, line 138, in cla
self.frame = self._frame
AttributeError: can’t set attribute

Markus Baden, on 2011-04-06 10:18, wrote:

Hi,

I draw four subplots that touch each other. Thus the "middle cross" of the
frame is drawn twice and appears to be thicker then the "outer rectangle". I
came across an old post for an custom Axes that would allow to only draw
part of the frame

Re: [Matplotlib-users] only left and bottom border in figure frame

However, when I run the example provided I get an "can't set attribute
error" (see traceback below). I use Python 2.7.1 |EPD 7.0-1 (32-bit) on Mac
OS 10.5.8, which includes matplotlib version 1.0.1.

Is there a fix to get the custom class running again, or is there an
alternative way to achieve what I intend?

Hi Markus,

I didn't look at that code but I think the alternative you're
looking for is

ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)

where you use the appropriate locations you want changed for the
different subplots axes.

If you're going to have a lot of subplots, you can simplify the
logic by first setting all spines to being invisible, and then
using ax.is_first_col(), is_first_row() and the corresponding
is_last_* methods to set the appropriate spines back to visible.

Like this:

#show only the outside spines
for ax in all_axes:
    for sp in ax.spines.values():
        sp.set_visible(False)
    if ax.is_first_row():
        ax.spines['top'].set_visible(True)
    if ax.is_last_row():
        ax.spines['bottom'].set_visible(True)
    if ax.is_first_col():
        ax.spines['left'].set_visible(True)
    if ax.is_last_col():
        ax.spines['right'].set_visible(True)

best,

···

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

Hi Paul,

Thanks a lot. That was exactly what I was looking for!

Best regards,

Markus

···

On Thu, Apr 7, 2011 at 1:14 AM, Paul Ivanov <pivanov314@…287…> wrote:

Markus Baden, on 2011-04-06 10:18, wrote:

Hi,

I draw four subplots that touch each other. Thus the “middle cross” of the

frame is drawn twice and appears to be thicker then the “outer rectangle”. I

came across an old post for an custom Axes that would allow to only draw

part of the frame

http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg10242.html

However, when I run the example provided I get an "can’t set attribute

error" (see traceback below). I use Python 2.7.1 |EPD 7.0-1 (32-bit) on Mac

OS 10.5.8, which includes matplotlib version 1.0.1.

Is there a fix to get the custom class running again, or is there an

alternative way to achieve what I intend?

Hi Markus,

I didn’t look at that code but I think the alternative you’re

looking for is

ax.spines[‘right’].set_visible(False)

ax.spines[‘bottom’].set_visible(False)

where you use the appropriate locations you want changed for the

different subplots axes.

If you’re going to have a lot of subplots, you can simplify the

logic by first setting all spines to being invisible, and then

using ax.is_first_col(), is_first_row() and the corresponding

is_last_* methods to set the appropriate spines back to visible.

Like this:

#show only the outside spines

for ax in all_axes:

for sp in ax.spines.values():

    sp.set_visible(False)

if ax.is_first_row():

    ax.spines['top'].set_visible(True)

if ax.is_last_row():

    ax.spines['bottom'].set_visible(True)

if ax.is_first_col():

    ax.spines['left'].set_visible(True)

if ax.is_last_col():

    ax.spines['right'].set_visible(True)

best,

Paul Ivanov

314 address only used for lists, off-list direct email at:

http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

-----BEGIN PGP SIGNATURE-----

Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk2cn4cACgkQe+cmRQ8+KPfCmACfTDkYFuGAz3zddfjIp963M3UK

Ve0AnRcvhQYcUnq/u8EU3Ap9fIkUUyLv

=mJHV

-----END PGP SIGNATURE-----


Xperia™ PLAY

It’s a major breakthrough. An authentic gaming

smartphone on the nation’s most reliable network.

And it wants your games.

http://p.sf.net/sfu/verizon-sfdev


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users