|
From: Markus B. <mar...@gm...> - 2011-04-06 02:18:40
|
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/mat...@li.../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 <module> 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 |
|
From: Paul I. <piv...@gm...> - 2011-04-06 17:15:11
|
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/mat...@li.../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 |
|
From: Markus B. <mar...@gm...> - 2011-04-11 03:15:14
|
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 <piv...@gm...> 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/mat...@li.../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(TM) 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |