|
From: James E. <jre...@ea...> - 2007-09-11 22:29:56
|
"""=0A=
plot using a variety of cm vs inches conversions. The example shows=0A=
how default unit instrospection works (ax1), how various keywords can=0A=
be used to set the x and y units to override the defaults (ax2, ax3,=0A=
ax4) and how one can set the xlimits using scalars (ax3, current units=0A=
assumed) or units (conversions applied to get the numbers to current=0A=
units)=0A=
=0A=
"""=0A=
from basic_units import cm, inch=0A=
from pylab import figure, show, nx=0A=
=0A=
cms =3D cm *nx.arange(0, 10, 2)=0A=
=0A=
fig =3D figure()=0A=
=0A=
ax1 =3D fig.add_subplot(2,2,1)=0A=
ax1.bar(cms, cms)=0A=
=0A=
ax2 =3D fig.add_subplot(2,2,2)=0A=
ax2.bar(cms, cms, xunits=3Dcm, yunits=3Dinch)=0A=
=0A=
ax3 =3D fig.add_subplot(2,2,3)=0A=
ax3.bar(cms, cms, xunits=3Dinch, yunits=3Dcm)=0A=
ax3.set_xlim(3, 6) # scalars are interpreted in current units=0A=
=0A=
ax4 =3D fig.add_subplot(2,2,4)=0A=
ax4.bar(cms, cms, xunits=3Dinch, yunits=3Dinch)=0A=
#fig.savefig('simple_conversion_plot.png')=0A=
ax4.set_xlim(3*cm, 6*cm) # cm are converted to inches=0A=
=0A=
show()=0A=
|