@@ -2591,33 +2591,43 @@ def plot(self, *args, **kwargs):
2591
2591
self .autoscale_view ()
2592
2592
return lines
2593
2593
2594
- def plot_date (self , d , y , fmt = 'bo' , tz = None , ** kwargs ):
2594
+ def plot_date (self , x , y , fmt = 'bo' , tz = None , xdate = True , ydate = False ,
2595
+ ** kwargs ):
2595
2596
"""
2596
- PLOT_DATE(d , y, fmt='bo', tz=None, **kwargs)
2597
+ PLOT_DATE(x , y, fmt='bo', tz=None, xdate=True, ydate=False , **kwargs)
2597
2598
2598
- d is a sequence of dates represented as float days since
2599
- 0001-01-01 UTC and y are the y values at those dates. fmt is
2600
- a plot format string. kwargs are passed on to plot. See plot
2601
- for more information.
2599
+ Similar to the plot() command, except the x or y (or both) data
2600
+ is considered to be dates, and the axis is labeled accordingly.
2601
+
2602
+ x or y (or both) can be a sequence of dates represented as
2603
+ float days since 0001-01-01 UTC.
2604
+
2605
+ fmt is a plot format string.
2606
+
2607
+ tz is the time zone to use in labelling dates. Defaults to rc value.
2608
+
2609
+ If xdate is True, the x-axis will be labeled with dates.
2610
+
2611
+ If ydate is True, the y-axis will be labeled with dates.
2612
+
2613
+ kwargs are passed on to plot. See plot for more information.
2602
2614
2603
2615
See matplotlib.dates for helper functions date2num, num2date
2604
2616
and drange for help on creating the required floating point dates
2605
-
2606
- tz is the timezone - defaults to rc value
2607
2617
"""
2608
2618
2609
2619
if not matplotlib ._havedate :
2610
2620
raise SystemExit ('plot_date: no dates support - dates require python2.3' )
2611
2621
2612
2622
if not self ._hold : self .cla ()
2613
2623
2614
- ret = self .plot (d , y , fmt , ** kwargs )
2615
-
2616
- span = self .dataLim .intervalx ().span ()
2624
+ ret = self .plot (x , y , fmt , ** kwargs )
2617
2625
2618
- locator , formatter = date_ticker_factory (span , tz )
2619
- self .xaxis .set_major_locator (locator )
2620
- self .xaxis .set_major_formatter (formatter )
2626
+ if xdate :
2627
+ self .xaxis_date (tz )
2628
+ if ydate :
2629
+ self .yaxis_date (tz )
2630
+
2621
2631
self .autoscale_view ()
2622
2632
2623
2633
return ret
@@ -3586,6 +3596,27 @@ def vlines(self, x, ymin, ymax, fmt='k-', **kwargs):
3586
3596
lines .append (line )
3587
3597
return lines
3588
3598
3599
+ def xaxis_date (self , tz = None ):
3600
+ """Sets up x-axis ticks and labels that treat the x data as dates.
3601
+
3602
+ tz is the time zone to use in labeling dates. Defaults to rc value.
3603
+ """
3604
+
3605
+ span = self .dataLim .intervalx ().span ()
3606
+ locator , formatter = date_ticker_factory (span , tz )
3607
+ self .xaxis .set_major_locator (locator )
3608
+ self .xaxis .set_major_formatter (formatter )
3609
+
3610
+ def yaxis_date (self , tz = None ):
3611
+ """Sets up y-axis ticks and labels that treat the y data as dates.
3612
+
3613
+ tz is the time zone to use in labeling dates. Defaults to rc value.
3614
+ """
3615
+
3616
+ span = self .dataLim .intervaly ().span ()
3617
+ locator , formatter = date_ticker_factory (span , tz )
3618
+ self .yaxis .set_major_locator (locator )
3619
+ self .yaxis .set_major_formatter (formatter )
3589
3620
3590
3621
def zoomx (self , numsteps ):
3591
3622
'Zoom in on the x xaxis numsteps (plus for zoom in, minus for zoom out)'
0 commit comments