## matplotlib-users

 [Matplotlib-users] Best way to set scales bounds to appropriate values From: neurino - 2011-02-09 10:53:24 Attachments: Message as HTML ```Hi, I'm a matplotlib newbie. An example is worth a thousand words: In [1]: matplotlib.__version__ Out[1]: '0.99.3' In [2]: a, b, x = np.zeros(10), np.ones(10), np.arange(10) In [3]: plot(x, a); plot(x, b) Well all I see is an empty plot with the two horizontal lines at y=0 and y=1 covered by the upper and lower frame lines. Why aren't bounds set a little more larger so the two lines can show properly??? I guess this is a common situation, for example 2 or more stable temperatures: the higher and the lower never show... How can I fix it? Thanks for your support. ```
 Re: [Matplotlib-users] Best way to set scales bounds to appropriate values From: Thomas Lecocq - 2011-02-09 12:23:54 Attachments: Message as HTML ```This will do : pyplot.xlim(-5,15) pyplot.ylim(-5,5) HTH. Thomas ********************** Thomas Lecocq Geologist Ph.D.Student (Seismology) Royal Observatory of Belgium ********************** Date: Wed, 9 Feb 2011 11:53:17 +0100 From: neurino@... To: matplotlib-users@... Subject: [Matplotlib-users] Best way to set scales bounds to appropriate values Hi, I'm a matplotlib newbie. An example is worth a thousand words: In [1]: matplotlib.__version__ Out[1]: '0.99.3' In [2]: a, b, x = np.zeros(10), np.ones(10), np.arange(10) In [3]: plot(x, a); plot(x, b) Well all I see is an empty plot with the two horizontal lines at y=0 and y=1 covered by the upper and lower frame lines. Why aren't bounds set a little more larger so the two lines can show properly??? I guess this is a common situation, for example 2 or more stable temperatures: the higher and the lower never show... How can I fix it? Thanks for your support. ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users ```
 Re: [Matplotlib-users] Best way to set scales bounds to appropriate values From: neurino - 2011-02-09 12:47:07 Attachments: Message as HTML ```Well, not that automatic... I wonder why matplotlib takes care of settings limits on data but fails in a common situation so I'm forced to override it every time because I don't know in advance what data I get... Thanks anyway. Cheers neurino 2011/2/9 Thomas Lecocq > This will do : > > pyplot.xlim(-5,15) > pyplot.ylim(-5,5) > > > HTH. > > Thomas > > ********************** > Thomas Lecocq > Geologist > Ph.D.Student (Seismology) > Royal Observatory of Belgium > ********************** > > > > ------------------------------ > Date: Wed, 9 Feb 2011 11:53:17 +0100 > From: neurino@... > To: matplotlib-users@... > Subject: [Matplotlib-users] Best way to set scales bounds to appropriate > values > > > Hi, I'm a matplotlib newbie. > > An example is worth a thousand words: > > In [1]: matplotlib.__version__ > Out[1]: '0.99.3' > > In [2]: a, b, x = np.zeros(10), np.ones(10), np.arange(10) > > In [3]: plot(x, a); plot(x, b) > > Well all I see is an empty plot with the two horizontal lines at y=0 and > y=1 covered by the upper and lower frame lines. > > Why aren't bounds set a little more larger so the two lines can show > properly??? > I guess this is a common situation, for example 2 or more stable > temperatures: the higher and the lower never show... > > How can I fix it? > > Thanks for your support. > > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. Find and fix more > than 250 security defects in the development cycle. Locate bottlenecks in > serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb > _______________________________________________ Matplotlib-users mailing > list Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ```
 Re: [Matplotlib-users] Best way to set scales bounds to appropriate values From: Thomas Lecocq - 2011-02-09 12:53:02 Attachments: Message as HTML ```Neurino I'm sure : 1° there must be a parameter in the default behaviour of the subplot to control taht 2° you can always set xlim( min(X)/2, max(X)/2 ) ... Thomas ********************** Thomas Lecocq Geologist Ph.D.Student (Seismology) Royal Observatory of Belgium ********************** Date: Wed, 9 Feb 2011 13:47:01 +0100 Subject: Re: [Matplotlib-users] Best way to set scales bounds to appropriate values From: neurino@... To: thlecocq@... CC: matplotlib-users@... Well, not that automatic... I wonder why matplotlib takes care of settings limits on data but fails in a common situation so I'm forced to override it every time because I don't know in advance what data I get... Thanks anyway. Cheers neurino 2011/2/9 Thomas Lecocq This will do : pyplot.xlim(-5,15) pyplot.ylim(-5,5) HTH. Thomas ********************** Thomas Lecocq Geologist Ph.D.Student (Seismology) Royal Observatory of Belgium ********************** Date: Wed, 9 Feb 2011 11:53:17 +0100 From: neurino@... To: matplotlib-users@... Subject: [Matplotlib-users] Best way to set scales bounds to appropriate values Hi, I'm a matplotlib newbie. An example is worth a thousand words: In [1]: matplotlib.__version__ Out[1]: '0.99.3' In [2]: a, b, x = np.zeros(10), np.ones(10), np.arange(10) In [3]: plot(x, a); plot(x, b) Well all I see is an empty plot with the two horizontal lines at y=0 and y=1 covered by the upper and lower frame lines. Why aren't bounds set a little more larger so the two lines can show properly??? I guess this is a common situation, for example 2 or more stable temperatures: the higher and the lower never show... How can I fix it? Thanks for your support. ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users ```
 Re: [Matplotlib-users] Best way to set scales bounds to appropriate values From: Benjamin Root - 2011-02-09 16:59:44 Attachments: Message as HTML ```On Wed, Feb 9, 2011 at 6:47 AM, neurino wrote: > Well, not that automatic... > > I wonder why matplotlib takes care of settings limits on data but fails in > a common situation so I'm forced to override it every time because I don't > know in advance what data I get... > > Thanks anyway. > > Cheers > neurino > > I did a little digging and I discovered a function I never noticed before... You can set a "margin" for an axis that can be used for autoscaling purposes. set_ymargin(self, m) method of matplotlib.axes.AxesSubplot instance Set padding of Y data limits prior to autoscaling. *m* times the data interval will be added to each end of that interval before it is used in autoscaling. accepts: float in range 0 to 1 So, in your code, if I set ymargin to 0.5, then the limits will automatically be -0.5 to 1.5. I think this is what you are looking for. Ben Root ```
 Re: [Matplotlib-users] Best way to set scales bounds to appropriate values From: neurino - 2011-02-09 20:30:12 Attachments: Message as HTML ```Thank you very much, that can help for sure! Unluckily matplotlib documentation is rather a jungle, just the lack of a methods/properties index for each class makes very hard to find what one's looking for. Thanks again. Greetings neurino 2011/2/9 Benjamin Root > On Wed, Feb 9, 2011 at 6:47 AM, neurino wrote: > >> Well, not that automatic... >> >> I wonder why matplotlib takes care of settings limits on data but fails in >> a common situation so I'm forced to override it every time because I don't >> know in advance what data I get... >> >> Thanks anyway. >> >> Cheers >> neurino >> >> > I did a little digging and I discovered a function I never noticed > before... You can set a "margin" for an axis that can be used for > autoscaling purposes. > > set_ymargin(self, m) method of matplotlib.axes.AxesSubplot instance > Set padding of Y data limits prior to autoscaling. > > *m* times the data interval will be added to each > end of that interval before it is used in autoscaling. > > accepts: float in range 0 to 1 > > So, in your code, if I set ymargin to 0.5, then the limits will > automatically be -0.5 to 1.5. > > I think this is what you are looking for. > > Ben Root > > ```