def test_polar_units(): import matplotlib.testing.jpl_units as units from nose.tools import assert_true units.register() pi = np.pi deg = units.UnitDbl(1.0, "deg") km = units.UnitDbl(1.0, "km") x1 = [pi / 6.0, pi / 4.0, pi / 3.0, pi / 2.0] x2 = [30.0 * deg, 45.0 * deg, 60.0 * deg, 90.0 * deg] y1 = [1.0, 2.0, 3.0, 4.0] y2 = [4.0, 3.0, 2.0, 1.0] fig = plt.figure() plt.polar(x2, y1, color="blue") # polar( x2, y1, color = "red", xunits="rad" ) # polar( x2, y2, color = "green" ) fig = plt.figure() # make sure runits and theta units work y1 = [y * km for y in y1] plt.polar(x2, y1, color="blue", thetaunits="rad", runits="km") assert_true( isinstance(plt.gca().get_xaxis().get_major_formatter(), units.UnitDblFormatter))
def float2epoch(value, unit): """: Convert a matplotlib floating-point date into an Epoch of the specified units. = INPUT VARIABLES - value The matplotlib floating-point date. - unit The unit system to use for the Epoch. = RETURN VALUE - Returns the value converted to an Epoch in the specified time system. """ # Delay-load due to circular dependencies. import matplotlib.testing.jpl_units as U secPastRef = value * 86400.0 * U.UnitDbl(1.0, 'sec') return U.Epoch(unit, secPastRef, EpochConverter.jdRef)
def test_polar_units(): import matplotlib.testing.jpl_units as units units.register() pi = np.pi deg = units.UnitDbl(1.0, "deg") x1 = [pi / 6.0, pi / 4.0, pi / 3.0, pi / 2.0] x2 = [30.0 * deg, 45.0 * deg, 60.0 * deg, 90.0 * deg] y1 = [1.0, 2.0, 3.0, 4.0] y2 = [4.0, 3.0, 2.0, 1.0] fig = pylab.figure() pylab.polar(x2, y1, color="blue") # polar( x2, y1, color = "red", xunits="rad" ) # polar( x2, y2, color = "green" ) fig.savefig('polar_units')