I would like to write the radian units of the axes as proportional to \pi
: something like
$\frac{\pi}{4}$, $\frac{\pi}{2}$, ...
in place of
0.785, 1.5707 ...
Is there any standard way? As an example, what should I add to the following code?
from pylab import *
x=arange(-10.0,10.0,0.1)
y= arctan(x)
plot(x,y,'b.')
show()
I found this example http://matplotlib.sourceforge.net/examples/units/radian_demo.html but it does not work because I don't have basic_units module.
Thank you!
To set labels on the x-axis and y-axis, use the plt. xlabel() and plt. ylabel() methods.
You can download the basic_units.py file here:
After it should work like this:
from pylab import *
from basic_units import radians
x = arange(-10.0,10.0,0.1)
y = map(lambda y: y*radians,arctan(x))
x = map(lambda x: x*radians,x)
plot(x,y,'b.',xunits=radians,yunits=radians)
show()
Alternatively you could implement the arctan function the way they implemented the cos function in basic_units.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With