I'm new to Matplotlib, I'm going to be plotting some temperature data
over time and wrote a test program to see with Matplotlab can do for
me. When I plot the the date the date time does not display as I would
expect, the date is output but the time is some type of counter not the
time of day as expected. What am I doing wrong? I've attached the
code, data and the resulting image. Any help would be greatly
Your plot tick labels are displaying month, day, and hour (the first
tick is at the start of August 16, the next is 3 hours later, etc.).
This is the default format for an axis of the length in your example.
The idea behind the scheme is to provide no more than 3 date time
numbers per tick label so as to keep the label from being too long.
You can override the default in two ways: by overriding one or more of
the formats used by the rather complex AutoDateFormatter (which is
designed to work with the default AutoDateLocator), or by specifying the
use of your own DateFormatter in which you directly provide the
strftime-style format string to use.
you can change the defaults used by AutoDateFormatter by specifying them
in a matplotlibrc file, or by setting them in the rcParams dictionary.
In the former case the change must be made before matplotlib is
imported; in the latter, it must be before the plot is made. Here are
commented-out values from the matplotlibrc template:
If you are plotting with a variety of axis spans, so that ticks are
placed at day multiples, or minute multiples, for example, then you
would have to use this method to change those corresponding defaults.
In your script you could add, for example:
This way you will have the same standard format regardless of the time
range spanned by your axis.
Also, instead of specifying the tick label rotation yourself, you might
want to use
which will place the end of the rotated string just below the tick.
On 2019/08/18 1:07 PM, Mike Sacauskis wrote:
> I'm new to Matplotlib, I'm going to be plotting some temperature data
> over time and wrote a test program to see with Matplotlab can do for
> me. When I plot the the date the date time does not display as I would
> expect, the date is output but the time is some type of counter not the
> time of day as expected. What am I doing wrong? I've attached the
> code, data and the resulting image. Any help would be greatly
> Matplotlib-users mailing list
> [hidden email] > https://mail.python.org/mailman/listinfo/matplotlib-users >