|
| 1 | +import numpy as np |
| 2 | +import matplotlib |
| 3 | +from matplotlib.testing.decorators import image_comparison, knownfailureif |
| 4 | +import matplotlib.pyplot as plt |
| 5 | +import pylab |
| 6 | + |
| 7 | +@knownfailureif('indeterminate', "Fails due to SF bug 2850075") |
| 8 | +@image_comparison(baseline_images=['empty_datetime']) |
| 9 | +def test_empty_datetime(): |
| 10 | + """Test plotting empty axes with dates along one axis.""" |
| 11 | + from datetime import datetime |
| 12 | + |
| 13 | + t0 = datetime(2009, 1, 20) |
| 14 | + tf = datetime(2009, 1, 21) |
| 15 | + |
| 16 | + fig = pylab.figure() |
| 17 | + pylab.axvspan( t0, tf, facecolor="blue", alpha=0.25 ) |
| 18 | + fig.autofmt_xdate() |
| 19 | + |
| 20 | + fig.savefig( 'empty_datetime' ) |
| 21 | + |
| 22 | +@image_comparison(baseline_images=['formatter_ticker_001', |
| 23 | + 'formatter_ticker_002', |
| 24 | + 'formatter_ticker_003', |
| 25 | + 'formatter_ticker_004', |
| 26 | + 'formatter_ticker_005', |
| 27 | + ]) |
| 28 | +def test_formatter_ticker(): |
| 29 | + """Test Some formatter and ticker issues.""" |
| 30 | + import matplotlib.testing.jpl_units as units |
| 31 | + def register_units(): |
| 32 | + """Register the unit conversion classes with matplotlib.""" |
| 33 | + import matplotlib.units as munits |
| 34 | + import matplotlib.testing.jpl_units as jpl_units |
| 35 | + from matplotlib.testing.jpl_units.Duration import Duration |
| 36 | + from matplotlib.testing.jpl_units.Epoch import Epoch |
| 37 | + from matplotlib.testing.jpl_units.UnitDbl import UnitDbl |
| 38 | + |
| 39 | + from matplotlib.testing.jpl_units.StrConverter import StrConverter |
| 40 | + from matplotlib.testing.jpl_units.EpochConverter import EpochConverter |
| 41 | + from matplotlib.testing.jpl_units.UnitDblConverter import UnitDblConverter |
| 42 | + |
| 43 | + munits.registry[ str ] = StrConverter() |
| 44 | + munits.registry[ Epoch ] = EpochConverter() |
| 45 | + munits.registry[ UnitDbl ] = UnitDblConverter() |
| 46 | + register_units() |
| 47 | + |
| 48 | + # This essentially test to see if user specified labels get overwritten |
| 49 | + # by the auto labeler functionality of the axes. |
| 50 | + xdata = [ x*units.sec for x in range(10) ] |
| 51 | + ydata1 = [ (1.5*y - 0.5)*units.km for y in range(10) ] |
| 52 | + ydata2 = [ (1.75*y - 1.0)*units.km for y in range(10) ] |
| 53 | + |
| 54 | + fig = pylab.figure() |
| 55 | + ax = pylab.subplot( 111 ) |
| 56 | + ax.set_xlabel( "x-label 001" ) |
| 57 | + fig.savefig( 'formatter_ticker_001' ) |
| 58 | + |
| 59 | + ax.plot( xdata, ydata1, color='blue', xunits="sec" ) |
| 60 | + fig.savefig( 'formatter_ticker_002' ) |
| 61 | + |
| 62 | + ax.set_xlabel( "x-label 003" ) |
| 63 | + fig.savefig( 'formatter_ticker_003' ) |
| 64 | + |
| 65 | + ax.plot( xdata, ydata2, color='green', xunits="hour" ) |
| 66 | + ax.set_xlabel( "x-label 004" ) |
| 67 | + fig.savefig( 'formatter_ticker_004' ) |
| 68 | + |
| 69 | + # See SF bug 2846058 |
| 70 | + # https://sourceforge.net/tracker/?func=detail&aid=2846058&group_id=80706&atid=560720 |
| 71 | + ax.set_xlabel( "x-label 005" ) |
| 72 | + ax.autoscale_view() |
| 73 | + fig.savefig( 'formatter_ticker_005' ) |
0 commit comments