Changeset 3038
- Timestamp:
- 06/29/15 18:52:29 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapplotter.py
r3016 r3038 1317 1317 return start,end 1318 1318 1319 def _get_date_axis_setup(self, dates ):1319 def _get_date_axis_setup(self, dates, axlim=None): 1320 1320 """ 1321 1321 Returns proper axis title and formatters for a list of dates … … 1323 1323 dates : a list of datetime objects returned by, 1324 1324 e.g. scantable.get_time(asdatetime=True) 1325 axlim : a tuple of min and max day range in the plot axis. 1326 if defined, the values are taken into account. 1325 1327 Output 1326 1328 a set of … … 1332 1334 from matplotlib import pylab as PL 1333 1335 from matplotlib.dates import DateFormatter 1334 from matplotlib.dates import HourLocator, MinuteLocator,SecondLocator, DayLocator 1336 from matplotlib.dates import HourLocator, MinuteLocator,SecondLocator, DayLocator, YearLocator, MonthLocator 1335 1337 t = PL.date2num(dates) 1336 tdel = max(t) - min(t) # interval in day 1338 tmin = min(t) 1339 tmax = max(t) 1340 if axlim is not None: 1341 tmin = min(tmin, min(axlim)) 1342 tmax = max(tmax, max(axlim)) 1343 tdel = tmax - tmin # interval in day 1337 1344 dstr = dates[0].strftime('%Y/%m/%d') 1338 if tdel > 1.0: # >1day 1345 if tdel > 365.0: # >1year (also the case for single or very small time range) 1346 majloc = YearLocator() 1347 minloc = MonthLocator(range(1,12,6)) 1348 timefmt = DateFormatter('%Y/%m/%d') 1349 elif tdel > 1.0: # >1day 1339 1350 dstr2 = dates[len(dates)-1].strftime('%Y/%m/%d') 1340 1351 dstr = dstr + " - " + dstr2 … … 1809 1820 1810 1821 # legend and axis formatting 1811 (dstr, timefmt, majloc, minloc) = self._get_date_axis_setup(alldates)1812 1822 ax = self.gca() 1823 (dstr, timefmt, majloc, minloc) = self._get_date_axis_setup(alldates, ax.get_xlim()) 1813 1824 ax.xaxis.set_major_formatter(timefmt) 1814 1825 ax.xaxis.set_major_locator(majloc)
Note:
See TracChangeset
for help on using the changeset viewer.