Re: [Matplotlib-users] changing the size of a plot point
On Mon, Oct 27, 2008 at 01:53:24PM -0700, Mathew Yeates wrote: is there a way, when plotting many points, to decrease the size of the point. With the default size I end up with overlapping points so some are not displayed. Do you want to change (decrease) the following values? plot(range(10), '.-', linewidth=3, markersize=15) # big values for testing I hope that helps. By, Friedrich - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Legend over plot lines
On Fri, Sep 26, 2008 at 12:52:01PM +0100, Peter Saffrey wrote: Is there a way to automatically resize plots (and subplots) and move/resize plot legends so that they don't obscure the plotted data? I have this problem especially on plots with 4 or 5 tracks. I can post an example, but I wasn't sure of the etiquette of posting images to this list. Yes as *.png. I think it's convinient to understand your problem in a few seconds. By, Friedrich - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] legend - markerscale does not work
On Wed, Sep 24, 2008 at 02:29:28PM +0900, Yong-Duk Jin wrote: Dear matplotlib users. I'm using matplotlib 0.98.3 from the packman repository on opensuse 11.0. I tried to adjust the 'markerscale option to enlarge a marker size in a legend. However, it simply did not work even in a simple code like following. from pylab import * x = [1,2,3]; y = [1,2,3] plot(x,y,ls='',marker='o',ms=1,label='test') legend(markerscale=5) show() I could only get a legend marker in a same size with the plot marker. I tried to reinstall all the packages related with python, including matplotlib, the legend marker size, however, does not change. Please help me here to change the legend marker size. Thanks. -- Yong-Duk Jin - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Problem with label displaying
On Sat, Sep 20, 2008 at 04:06:36PM +0200, Laurent Dufrechou wrote: Hello all, I'm trying to show to a friend matplotlib features via pylab interface. (thus to replace matlab/scilab) I've a little problem while I'm trying to display plots into subplots here under vista. If I add a pylab.xlabel to the subplots they are masked by the underlying subplot. To workaround it I need to change the window size. I used for myself add_axes([0.1,0.8,0.75,.15]) but that's not that easy. That's right (but sometimes I did the same :-) Do I miss one important thing or must I go trought add_axes functions each time I call pylab.subplot? Yes, you can adjust the space between the subplot with subplots_adjust() Look at the docstring with In [1]: subplots-adjust? in ipython shell. Try to see the difference between figure() subplot(211) subplot(212) show() and figure() subplots_adjust(hspace=0.4) # standard: 0.2 subplot(211) subplot(212) show() By, Friedrich - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] save or pickle figure object
On Wed, Sep 17, 2008 at 12:55:40PM -0700, Ted Drain wrote: I agree completely - I was just pointing that it is possible. I think what people might not be aware of is that it's really an all or nothing proposition. You either jump in completely and pay the large cost to handle this in a maintainable, scalable way or don't do it at all. All of the quick and easy solutions have too many problems and aren't really maintainable. Here is my (easy and maintainable) way to handle the versions for my graphics: * I write the data creation in a python script * I write the creation of the mpl graphics in a script (most the same) * I manage these python file with a version-system (eg mercurial) So I have different versions for my mpl graphics and I can modify the graphic any time (with a new python run). If the data creation takes too long, I could save the data in an extra file (eg pickle file) and versioning the pickled file. So I dont need an extra way to reedit a mpl graphic. By, Friedrich - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Python Distribution with matplotlib
Hello, today I tried to install mpl in my local home directory at work. This debian distribution is very old and I had to compile for my own. But I failed to compile pygtk (special cairo and pango) as a dependency for mpl. So I have two questions: 1. Does you have an advice to compile mpl with minimal dependencies? 2. Does anybody know a good python dirstibution including mpl? Thanks, Friedrich - Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] add an arrow to a lineEnd
On Tue, Jun 03, 2008 at 03:55:48PM +0200, Friedrich Hagedorn wrote: I want do add an arrow *tip* to a line with the same angle. It should behave like a marker: it should not resize when I zoom in. By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] add an arrow to a lineEnd
Hello, I want do add an arrow *tip* to a line with the same angle. I have tried this: from pylab import * from matplotlib import collections, transforms def MyArrow(ax, x, y, ang, scale=50, over=.5, color='k'): ar = [(0,0), (-.5,-over), (0,1), (.5,-over), (0,0)] col = collections.PolyCollection( [ar], offsets=(x, y), transOffset=ax.transData, color=color ) col.set_transform(transforms.Affine2D().rotate(ang).scale(scale)) ax.add_collection(col) plot([0,1,2], '.-', lw=2) MyArrow(gca(), .5, .5, -pi/4) draw() and I get an arrow tip without the same line angle :-( See the attached image. Can you help me to get the right transformation? Thanks, Friedrich attachment: arrow.png- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] add an arrow to a lineEnd
Hello, the original problem that I have is to add an arrow to the end of a plotted line. I tried this from pylab import * x=linspace(0, 1.85, 100) y=sin(x) dx=x[-1] - x[-2] dy=y[-1] - y[-2] plot(x,y,lw=2) arrow(x[-2], y[-2], dx, dy, width=.02, length_includes_head=True, head_length=sqrt(dx**2+dy**2), lw=0, overhang=.1) But this is ugly. And when I zoom in the arrowsize isnt scaled with the linewidth. Any idea instead to switch to the pyx package? By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] New pgf backend for LaTex?
Hello, are there plan to implement a new backend for the latex proper use which create the drawing comand in the pgf language? With this kind of graphic creation I could overcome all the (font-) scaleing problems I have when I want to include a mpl graphic in my latex document. Even gnuplot has such an backend but I dont want to use it anymore :-) By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] New pgf backend for LaTex?
On Fri, May 23, 2008 at 10:51:05AM -0400, Darren Dale wrote: On Friday 23 May 2008 10:35:14 am Friedrich Hagedorn wrote: Hello, are there plan to implement a new backend for the latex proper use which create the drawing comand in the pgf language? With this kind of graphic creation I could overcome all the (font-) scaleing problems I have when I want to include a mpl graphic in my latex document. I'm not familiar with pgf, could you provide some more information? pgf is a tex-based graphic language similar to ps-tricks but also for pdftex. There are very nice graphics: http://www.ctan.org/get/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf The basic drawing is like this (a cross) \begin{tikzpicture} \draw (-1.5,0) -- (1.5,0); % horizontal line \draw (0,-1.5) -- (0,1.5); % vertical line \draw (1,1) node{$y=x^2$}; % text label \end{tikzpicture} There also exsits makro pakages for (more ore less convinent) data plots but then you dont have the nice python interface. What problems do you have with font scaling, and what additional capabilities do you think such an approach would offer? I want that fonts in the mpl graphics have the same (or otherwise related) proerties as the main-font in my latex document. So, therefore I have to know all the font properties from my latex document (\normalfont): type, family, size. The next problem is that the standard size of the mpl graphic (8, 6) inches is too big for my latex document (0.5\linewidth). Therefore I must scale the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But with this scaling the font in the mpl graphic are also scaled and I have no chance adapeting the two fonts (mpl, latex) without manual iterations. Ok, I could adjust the figsize but the last time I did it (long time ago) there were other misplaced objects in the mpl graphic (I dont remember exactly, sorry). But if I had the whole mpl graphic as pgf commands there would be no problem with the font stuff, scaleing and line widths. And may be you could extend the mpl graphic with some tricky (and eye candy) pgf extensions (ok I am also a beginner with the pgf language but its realy powerfull). BTW. In the same way I can create very nice ciruit schematic with CircuitMacros www.ece.uwaterloo.ca/~aplevich/Circuit_macros/html/examples.pdf I hope you could understand what I mean :-) By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] New pgf backend for LaTex?
On Fri, May 23, 2008 at 05:30:02PM +0200, Friedrich Hagedorn wrote: The next problem is that the standard size of the mpl graphic (8, 6) inches is too big for my latex document (0.5\linewidth). Therefore I must scale the mpl graphic (\includegraphics[width=0.5\linewidth]{...}). But with this scaling the font in the mpl graphic are also scaled and I have no chance adapeting the two fonts (mpl, latex) without manual iterations. Ok, I could adjust the figsize but the last time I did it (long time ago) there were other misplaced objects in the mpl graphic (I dont remember exactly, sorry). I tried this now with (width = 7cm = 2.67in) In [1]: figure(figsize=(2.67,2)) Out[1]: matplotlib.figure.Figure object at 0x8c3b36c In [2]: subplot(111) Out[2]: matplotlib.axes.AxesSubplot object at 0x8c3b3ec and the problem is that the remaining (abolute) space of the margin ist too small for the whole labeling (ticks and axis). But I dont want to adjust all the default values every time a what a plot in my latex document. On Fri, May 23, 2008 at 12:00:03PM -0400, Darren Dale wrote: Wouldn't this cause some problems with how the text is layed out on the canvas? The way it works now, a title can be centered over the axes because the extents of the text are known. If you allow the fonts and font sizes to be dictated by the latex document, they will end up being positioned incorrectly. Shortly: Yes this is a problem but pgf could solve it. I dont know it exactly but if you do all the graphic stuff with pgf in latex so you can adjust the text boxes in a various way in respect to different points. E.g. baseline -left, -right, -center and so on. This is explaind in the pgfmanual in section 53.3.3. If I fly over the pgfmanual I get the impression that I could do everything with it :-) But to do this its a hard work (for beginners). Therefore I like to have the convinient pylab-interface to create pretty standard plots for latex. By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Set the right reply adress
Hello List-Admin, could you set the right reply-adress in the mails from the matplotlib mailinglist? Everytime when I what to reply to a message I have to set the right email-adress to matplotlib-users@lists.sourceforge.net otherwise the email would sent only as a privat mail. I use mutt and on all other mailinglist I have no problem. So I think this is a matplotlib-ml problem. Thanks, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Legend labels - interaction with functions
On Thu, May 22, 2008 at 02:52:13PM +0200, David Simpson wrote: This is probably my lack of knowledge of python, but how do I set up legend labels for some bar-plots that have been produced inside a function. For example, the following will nicely plot my bar-plots, but then legend doesn't know about the colours used, so here just uses black for both labels. I'd like the labels to have the same colour as the bars generated inside plotb. (I am using a function here as my real code has extra stuff to calculate error-bars and suchlike for each data set.) x=arange(0,5) y=array([ 1.2, 3.4, 5.4, 2.3, 1.0]) z=array([ 2.2, 0.7, 0.4, 1.3, 1.2]) def plotb(x,y,col): p=bar(x,y,color=col) plotb(x,y,'k') plotb(x+0.4,z,'y') legend(('YYY,'ZZZ')) I tried passing the object p through the plotb argument list, but python didn't like that. (I am just learning python, and so far haven't seen how to pass such objects around. You could return the plotted lines from the function plotb. Here is my attempt: In [1]: x=arange(0,5) In [2]: y=array([ 1.2, 3.4, 5.4, 2.3, 1.0]) In [3]: z=array([ 2.2, 0.7, 0.4, 1.3, 1.2]) In [4]: def plotb(x,y,col): ...: lines = bar(x,y,color=col) ...: return lines ...: In [5]: l1 = plotb(x,y,'k') In [6]: l2 = plotb(x+0.4,z,'y') In [7]: legend((l1[0], l2[0]), ('YYY','ZZZ')) Out[7]: matplotlib.legend.Legend object at 0x908dc6c The legend() function could label any line object. So every single bar-line could be listed in the legend. But I think you would only have one from each color, so I have choosen the first: l1[0] and l2[0]. Is this what you what? By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] changing ticklabels color
On Thu, May 22, 2008 at 02:30:24PM +, Chiara Caronna wrote: Hello, I would like to change the color of the yticklabels. I tried to use this command: ax1=p.subplot(212) [...] ax1.set_yticklabels(color='r') * Solution 1: In [1]: ax1=subplot(111) In [2]: setp(ax1.get_yaxis().get_major_ticklabels(), color='r') * Solution 2: In [1]: ax1=subplot(111) In [2]: for label in ax1.get_yaxis().get_majorticklabels(): ...: label.set_color('r') ...: ...: In [3]: draw() May be there is a shorter solution but I dont know of it :-) By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Set the right reply adress
On Thu, May 22, 2008 at 05:59:23PM +0300, Jouni K. Seppänen wrote: Friedrich Hagedorn [EMAIL PROTECTED] writes: could you set the right reply-adress in the mails from the matplotlib mailinglist? This is something of a controversial issue. One side is presented at http://www.unicom.com/pw/reply-to-harmful.html and I'm sure the other one has a web page somewhere, too. On lists that do not munge the reply-to address, such as the matplotlib lists, you have two options: you can reply to the sender only ('r' in mutt) or reply to everyone ('g'). On lists that do munge the address, both commands reply to the complete list. Ok, I test it with 'g' by this reply, and it works. I hope I can change my habit to type 'g' instead of 'r'. On Thu, May 22, 2008 at 04:59:39PM +0200, Johann Rohwer wrote: This has been discussed before. See: http://sourceforge.net/mailarchive/message.php?msg_id=4756A726.1080104%40gmx.net Ah, I see the discussion. I am for 'r' :-) By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Tick labels and subscripts
On Thu, May 22, 2008 at 03:25:41PM -0700, Christopher Brown wrote: Hi Users, What is the best way to add a subscript to a tick label using the default font? Hm, could you give a short example of what you want? I do subscripts with this code: In [1]: subplot(111) Out[1]: matplotlib.axes.AxesSubplot object at 0x8cbbf2c In [2]: xticks((0, 0.5, 1), (r'$t_0$', r'$t_1$', r'$t_2$'), fontsize=18) Out[2]: ([matplotlib.axis.XTick object at 0x8cd028c, matplotlib.axis.XTick object at 0x8ffb0ac, matplotlib.axis.XTick object at 0x8ffb0cc], a list of 3 Text xticklabel objects) But sure this is not the best way to do it :-) By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] distance between tick label and xlabel
On Wed, May 21, 2008 at 11:13:55AM -0700, Christopher Brown wrote: I am changing this property, but nothing changes on the figure. From ipython, and when the figure is visible, I type: gca().yaxis.labelpad = 100 but the ylabel doesn't move. I'm in 0.98pre from svn. What am I doing wrong? Yust a guess: Try draw() to redraw the hole figure. By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Bug in axhline
Hello, I think the following is'nt right: In [1]: plot([1,2,3]) Out[1]: [matplotlib.lines.Line2D object at 0x8f9b0ec] In [2]: ylim(-4,4) Out[2]: (-4, 4) In [3]: axhline() Out[3]: matplotlib.lines.Line2D object at 0x8f9bc0c In [4]: ylim() Out[4]: (0.0, 3.0) By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Bug in axhline
On Thu, May 15, 2008 at 10:20:23AM +0200, Friedrich Hagedorn wrote: Hello, I think the following is'nt right: In [1]: plot([1,2,3]) Out[1]: [matplotlib.lines.Line2D object at 0x8f9b0ec] In [2]: ylim(-4,4) Out[2]: (-4, 4) In [3]: axhline() Out[3]: matplotlib.lines.Line2D object at 0x8f9bc0c In [4]: ylim() Out[4]: (0.0, 3.0) With the attached patch the thinks are ok: In [1]: plot([1,2,3]) Out[1]: [matplotlib.lines.Line2D object at 0x8f9b0ac] In [2]: ylim(-4,4) Out[2]: (-4, 4) In [3]: xlim(-4,4) Out[3]: (-4, 4) In [4]: axhline() Out[4]: matplotlib.lines.Line2D object at 0x8fa6e6c In [5]: axvline() Out[5]: matplotlib.lines.Line2D object at 0x9062fec In [6]: xlim() Out[6]: (-4.0, 4.0) In [7]: ylim() Out[7]: (-4.0, 4.0) By, Friedrich Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (Revision 5008) +++ lib/matplotlib/axes.py (Arbeitskopie) @@ -2435,9 +2435,14 @@ %(Line2D)s +autoscale = self.get_autoscale_on() +self.set_autoscale_on(False) + trans = mtransforms.blended_transform_factory( self.transAxes, self.transData) l, = self.plot([xmin,xmax], [y,y], transform=trans, scalex=False, **kwargs) + +self.set_autoscale_on(autoscale) return l axhline.__doc__ = cbook.dedent(axhline.__doc__) % martist.kwdocd @@ -2472,9 +2477,14 @@ %(Line2D)s +autoscale = self.get_autoscale_on() +self.set_autoscale_on(False) + trans = mtransforms.blended_transform_factory( self.transData, self.transAxes) l, = self.plot([x,x], [ymin,ymax] , transform=trans, scaley=False, **kwargs) + +self.set_autoscale_on(autoscale) return l axvline.__doc__ = cbook.dedent(axvline.__doc__) % martist.kwdocd - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Bug in axhline
On Thu, May 15, 2008 at 01:56:19PM -0500, John Hunter wrote: On Thu, May 15, 2008 at 3:41 AM, Friedrich Hagedorn [EMAIL PROTECTED] wrote: On Thu, May 15, 2008 at 10:20:23AM +0200, Friedrich Hagedorn wrote: Hello, I think the following is'nt right: In [1]: plot([1,2,3]) Out[1]: [matplotlib.lines.Line2D object at 0x8f9b0ec] In [2]: ylim(-4,4) Out[2]: (-4, 4) In [3]: axhline() Out[3]: matplotlib.lines.Line2D object at 0x8f9bc0c [...] For example, consider this case plot([1,2,3]) ylim(-4,4) axhline(20) What we want is to autoscale only if autoscale_on=True *and* the hline is outside the current bounds. Something like: ymin, ymax = self.get_ylim() if ymaxymin: ymin, ymax = ymax, ymin scaley = (yymin) or (yymax) trans = mtransforms.blended_transform_factory( self.transAxes, self.transData) l, = self.plot([xmin,xmax], [y,y], transform=trans, scalex=False, scaley=scaley, **kwargs) I just committed this to svn in r5141 so give it a test drive and let me know what you think. You are right. This patch works fine for me, thanks. There is an unrelated problem with the autoscaler which is that in the example plot([1,2,3]) axhline(20) it sets ymax to 20 making the hline invisible. But there is no problem with axhline(20.2) Thats why the autoscale sets the outer ticks to the boundaries. We should probably force the ylimits to be strictly outside the data limits in some cases when autoscaling. I think this would be better then the current (undefined) behaviour (sometimes the datalines touches the boundaries and sometimes not). For my own stuff I have used gca().set_ylim(ax.dataLim.intervaly*1.2) for a 'autoscale' replacement. By, Friedrich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users