[Tutor] pylab axis
Mark Lawrence
breamoreboy at yahoo.co.uk
Thu May 29 21:26:58 CEST 2014
On 29/05/2014 17:12, Sydney Shall wrote:
> I would like to start by thanking all the tutors for their wonderful
> genourosity and excellent advice.
>
> My problem concerns forcing pylab to give me the y axis I want.
>
> My code is as follows:
>
> pylab.figure(10)
>
> pylab.title("Ratio of realised capital to advanced capital.")
>
> pylab.xlabel("Time [Cycles of Capital reproduction]")
>
> pylab.ylabel("Ratio of realised capital to advanced capital.")
>
> pylab.xlim = ((0.0, 1.5))
>
> pylab.plot(cycles, ratiocrtoca)
>
> pylab.show(10)
>
>
> My pylab output is as follows:
>
>
> I regret I do not know how to put the pdf file in the message, so I have
> attached the pdf file of the graph. Please guide me on this too.
>
> My problem is that I wish to force the y axis to simply be from 0.0 to
> 1.5 without the detail which is just arithmetic noise, I think.
>
> With thanks,
>
> Sydney
>
> --
> Sydney Shall
>
The joys of the interactive prompt.
In [3]: help(pylab.ylim)
Help on function ylim in module matplotlib.pyplot:
ylim(*args, **kwargs)
Get or set the *y*-limits of the current axes.
::
ymin, ymax = ylim() # return the current ylim
ylim( (ymin, ymax) ) # set the ylim to ymin, ymax
ylim( ymin, ymax ) # set the ylim to ymin, ymax
If you do not specify args, you can pass the *ymin* and *ymax* as
kwargs, e.g.::
ylim(ymax=3) # adjust the max leaving min unchanged
ylim(ymin=1) # adjust the min leaving max unchanged
Setting limits turns autoscaling off for the y-axis.
The new axis limits are returned as a length 2 tuple.
Aside, you appear to be using matplotlib in a strange way. If your code
is in a script, you'd use a line like this.
import matplotlib.pyplot as plt
If you're working interactively you'd use.
from pylab import *
You have a half way house.
Finally this mailing list is mainly aimed at people learning the Python
language and not third party modules. For matplotlib you can find a
very helpful group here gmane.comp.python.matplotlib.general (and other
places), I know they don't bite as I've been there :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
More information about the Tutor
mailing list