[Matplotlib-users] Controlling the number of displayed digits in time axis labels
William Ray Wing
wrw at mac.com
Tue Nov 8 08:15:34 EST 2016
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.
…………………cut on dotted line…………
#! /usr/bin/env python
import pandas as pd, matplotlib.pyplot as plt, numpy as np
# Next plot
ax = axs[0,1]
x_format = mpdates.DateFormatter('%H:%M:%S')
ax.axis([dndx,dndx[vec_len-1], 12000, 15500])
# Next plot
ax = axs[1,0]
> 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 <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?
> 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.
> Matplotlib-users mailing list
> Matplotlib-users at python.org <mailto:Matplotlib-users at python.org>
> https://mail.python.org/mailman/listinfo/matplotlib-users <https://mail.python.org/mailman/listinfo/matplotlib-users>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users