[Matplotlib-users] Relpos only works once when using FancyArrow for annotation
Hi list, I'm trying to annotate points on a graph by drawing a simple line from the point on the axis to the top left corner of the text. I can't figure out, how to use pyplot.annotate so that it turns of the arrow head and I can use horizontalalignment (ha) and verticalalignment (va). When I use arrowstyle='-' in the arrowprops dictionary ha and va don't work. Instead I use relpos=(0, 1) in the arrowprops dictionary, which works, but only when I call the annotate function the first time. Below is a minimal example. I'm using mpl version 1.0. as part of EPD 7.1 on Mac OS X 10.5. Any hints on how to achieve my goal would be greatly appreciated! Best regards, Markus --- The following code reproduces my problem import numpy as np import matplotlib.pyplot as plt data = np.linspace(1,10) plt.plot(data, data) anno_args = { 'annotation_clip': False, 'arrowprops': dict(arrowstyle='-', relpos=(0, 1)), } plt.annotate('Good relpos', (3, 3), xytext = (3, 2), **anno_args) plt.annotate('Bad relpos', (6, 6), xytext = (6, 5), **anno_args) plt.annotate('No ha/va', (5, 5), xytext = (5, 4), arrowprops=dict(arrowstyle='-'), ha='left', va='top') plt.show() -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Relpos only works once when using FancyArrow for annotation
This is a bug. In the current implementation, annotate has a side-effect that modifies the arrowprops dictionary. As a workaround, you may do, arrowprops = dict(arrowstyle='-', relpos=(0, 1)) plt.annotate('Good relpos', (3, 3), xytext = (3, 2), annotation_clip=False, arrowprops=arrowprops.copy()) Works for me. Thanks a lot! plt.annotate('No ha/va', (5, 5), xytext = (5, 4), arrowprops=dict(arrowstyle='-'), ha='left', va='top') ha and va controls the location of the text relative to the xytext, and I believe it does work as expected. It has nothing to do with the starting point of the arrow, which should be controlled by the relpos parameter. Thanks for clarifying. Regards, Markus -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Draw only left and top part of frame
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 pivanov...@gmail.com 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(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 Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- 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 Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] 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@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? 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 -- 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 Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Building matplotlib from source with libpng (png.h) installed via fink on Mac OS X
On Aug 11, 2010, at 6:09 AM, Friedrich Romstedt wrote: Are you on OSX 10.5 or 10.6? I'm asking because it's important for others when you're on 10.5 because you're using gcc-4.0 then, while 10.6 users have at least for non-Python (distutils) compilations gcc-4.2 as default. I'm running Mac OS X 10.5.8. Markus -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Building matplotlib from source with libpng (png.h) installed via fink on Mac OS X
On Aug 10, 2010, at 5:34 AM, Friedrich Romstedt wrote: 2010/8/9 Markus Baden markus.ba...@gmail.com: On my Macbook Pro I use Python 2.6 as provided by the Enthought Python Distribution. I ran into some problem with Axes3D so I decided to upgrade to the latest version from source. While trying that I got a similiar error message as discussed in http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg12938.html i.e. error: png.h: No such file or directory In short matplotlib could not find libpng (or png.h from that). I had libpng installed via fink in the usual place /sw/include etc. This seems to be a quite natural choice, so I wondered why matplotlib does not find that out of the box. Following the tips in the above post I looked at basedir in setupext.py For some reason the basedirs for darwin where commented out. Uncommenting the basedirs did the trick for me [1] and matplotlib happily installed with the libpng from fink. Hope this will help other mac users. Thanks for the great work on matplotlib! Thanks for reporting finally a working pure-setup.py installation! But are you sure it really works, because mixing binary-distributed and self-compiled packages often leads to import refusal, when the external libraries (as freetype) are compiled with a different compiler than Python. Thanks for the warning. Not really sure. So far I have seen no problems, i.e. can happily plot. How can I make sure that I don't ran into those problems? I usually don't mix packages and just hope that the EPD guys update to Matplotlib 1.0 soon. Markus -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Building matplotlib from source with libpng (png.h) installed via fink on Mac OS X
Hi, On my Macbook Pro I use Python 2.6 as provided by the Enthought Python Distribution. I ran into some problem with Axes3D so I decided to upgrade to the latest version from source. While trying that I got a similiar error message as discussed in http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg12938.html i.e. error: png.h: No such file or directory In short matplotlib could not find libpng (or png.h from that). I had libpng installed via fink in the usual place /sw/include etc. This seems to be a quite natural choice, so I wondered why matplotlib does not find that out of the box. Following the tips in the above post I looked at basedir in setupext.py For some reason the basedirs for darwin where commented out. Uncommenting the basedirs did the trick for me [1] and matplotlib happily installed with the libpng from fink. Hope this will help other mac users. Thanks for the great work on matplotlib! Cheers, Markus [1] Here the relevant lines for setupext.py 'darwin' : ['/sw/lib/freetype2', '/sw/lib/freetype219', '/usr/ local', '/usr', '/sw'], # it appears builds with darwin are broken because of all the # different flags the deps can be compile with, so I am pushing # people to : # make -f make.osx fetch deps mpl_build mpl_install #'_darwin' : [], -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users