Controlling the number of displayed digits in time axis labels

I need to plot some time series data in which the time axis is specified by numpy/pandas 64-bit date-time values. I?m only interested in hours, minutes, and seconds, and the seconds value is only accurate to hundredths. I?m formatting the time axis as:

x_format = mathplotlib.dates.DateFormatter('%H:%M:%S?)

which gives me hours, minutes, and seconds, BUT gives me six digits of bogus precision after the seconds decimal point. Is there any way to truncate those six digits to three. I?ve tried several Google searches, but have been unsuccessful in coming up with anything.

Thanks,
Bill

The defaults will be improved in 2.0 (see
http://matplotlib.org/devdocs/users/dflt_style_changes.html#autodateformatter-format-strings
)

Can you provide a more complete example of what you are doing that is not
working?

Tom

···

On Mon, Nov 7, 2016 at 11:31 PM William Ray Wing <wrw at mac.com> wrote:

I need to plot some time series data in which the time axis is specified
by numpy/pandas 64-bit date-time values. I?m only interested in hours,
minutes, and seconds, and the seconds value is only accurate to
hundredths. I?m formatting the time axis as:

x_format = mathplotlib.dates.DateFormatter('%H:%M:%S?)

which gives me hours, minutes, and seconds, BUT gives me six digits of
bogus precision after the seconds decimal point. Is there any way to
truncate those six digits to three. I?ve tried several Google searches,
but have been unsuccessful in coming up with anything.

Thanks,
Bill
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20161108/bb015e54/attachment.html&gt;

Sure (and thanks for helping me with this). The data is read from a csv file, the pieces I?m looking at are extracted and I generate four sub-plots, the first of which axs[0,0] is NOT a time series, but the next three are. The code below includes my imports and the code to generate the second and third sub-plot. The second, third, and last sub-plots all have the same time axis, but the labels are only drawn on the bottom two (1,0 and 1,1). I assume if I explicitly made space under the 0,0 and 0,1 plots, they would grow labels too.
Thanks,
Bill

???cut on dotted line???

#! /usr/bin/env python
import pandas as pd, matplotlib.pyplot as plt, numpy as np
import matplotlib.dates
  .
  .
  .

···

#
# Next plot
#
ax = axs[0,1]
x_format = mpdates.DateFormatter('%H:%M:%S')
ax.xaxis.set_major_formatter(x_format)
fig.autofmt_xdate()
ax.plot(wdx,wdyH2Oc_, 'b')
ax.axis([dndx[0],dndx[vec_len-1], 12000, 15500])
ax.set_title('H2Oc_ppm')
#
# Next plot
#
ax = axs[1,0]
ax.plot(wdx,wdyO18_d)
ax.set_title('O18_del')
ax.axis([dndx[0], dndx[vec_len-1],-55,-25])

On Nov 7, 2016, at 11:47 PM, Thomas Caswell <tcaswell at gmail.com> wrote:

The defaults will be improved in 2.0 (see http://matplotlib.org/devdocs/users/dflt_style_changes.html#autodateformatter-format-strings )

Can you provide a more complete example of what you are doing that is not working?

Tom

On Mon, Nov 7, 2016 at 11:31 PM William Ray Wing <wrw at mac.com <mailto:wrw at mac.com>> wrote:
I need to plot some time series data in which the time axis is specified by numpy/pandas 64-bit date-time values. I?m only interested in hours, minutes, and seconds, and the seconds value is only accurate to hundredths. I?m formatting the time axis as:

x_format = mathplotlib.dates.DateFormatter('%H:%M:%S?)

which gives me hours, minutes, and seconds, BUT gives me six digits of bogus precision after the seconds decimal point. Is there any way to truncate those six digits to three. I?ve tried several Google searches, but have been unsuccessful in coming up with anything.

Thanks,
Bill
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org <mailto:Matplotlib-users at python.org>
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20161108/023a2c08/attachment.html&gt;