def test_axhspan_epoch(): from datetime import datetime import matplotlib.testing.jpl_units as units units.register() # generate some data t0 = units.Epoch("ET", dt=datetime(2009, 1, 20)) tf = units.Epoch("ET", dt=datetime(2009, 1, 21)) dt = units.Duration("ET", units.day.convert("sec")) fig = plt.figure() plt.axhspan(t0, tf, facecolor="blue", alpha=0.25) ax = plt.gca() ax.set_ylim(t0 - 5.0 * dt, tf + 5.0 * dt)
def test_jpl_bar_units(): import matplotlib.testing.jpl_units as units units.register() day = units.Duration("ET", 24.0 * 60.0 * 60.0) x = [0*units.km, 1*units.km, 2*units.km] w = [1*day, 2*day, 3*day] b = units.Epoch("ET", dt=datetime(2009, 4, 25)) fig, ax = plt.subplots() ax.bar(x, w, bottom=b) ax.set_ylim([b-1*day, b+w[-1]+(1.001)*day])
def test_jpl_barh_units(): from datetime import datetime import matplotlib.testing.jpl_units as units units.register() day = units.Duration("ET", 24.0 * 60.0 * 60.0) x = [0*units.km, 1*units.km, 2*units.km] w = [1*day, 2*day, 3*day] b = units.Epoch("ET", dt=datetime(2009, 4, 25)) fig, ax = plt.subplots() ax.barh(x, w, left=b) ax.set_xlim([b-1*day, b+w[-1]+1*day])
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_fill_units(): from datetime import datetime import matplotlib.testing.jpl_units as units units.register() # generate some data t = units.Epoch("ET", dt=datetime(2009, 4, 27)) value = 10.0 * units.deg day = units.Duration("ET", 24.0 * 60.0 * 60.0) fig = pylab.figure() # Top-Left ax1 = fig.add_subplot(221) ax1.plot([t], [value], yunits='deg', color='red') ax1.fill([733525.0, 733525.0, 733526.0, 733526.0], [0.0, 0.0, 90.0, 0.0], 'b') # Top-Right ax2 = fig.add_subplot(222) ax2.plot([t], [value], yunits='deg', color='red') ax2.fill([t, t, t + day, t + day], [0.0, 0.0, 90.0, 0.0], 'b') # Bottom-Left ax3 = fig.add_subplot(223) ax3.plot([t], [value], yunits='deg', color='red') ax1.fill([733525.0, 733525.0, 733526.0, 733526.0], [0 * units.deg, 0 * units.deg, 90 * units.deg, 0 * units.deg], 'b') # Bottom-Right ax4 = fig.add_subplot(224) ax4.plot([t], [value], yunits='deg', color='red') ax4.fill([t, t, t + day, t + day], [0 * units.deg, 0 * units.deg, 90 * units.deg, 0 * units.deg], facecolor="blue") fig.autofmt_xdate() fig.savefig('fill_units')