I have a dataset with datetimes that sometimes contain differences in seconds.
I have the datetimes (on x-axis) displayed vertically in hopes that the text won't overlap each other, but from the looks of it they're stacked practically on top of each other. I think this is because I have data that differ in seconds and the dates can range through different days, so the x-axis is very tight. Another problem with this is that the datapoints on the graph are also overlapping because the distance between them is so tight.
Here's an example set (already converted using date2num()
). It differs in seconds, but spans over several days:
dates = [734949.584699074, 734959.4604050926, 734959.4888773148, 734949.5844791667, 734959.037025463, 734959.0425810185, 734959.0522916666, 734959.4607060185, 734959.4891435185, 734949.5819444444, 734959.0348726852, 734959.0390393519, 734959.0432175926, 734959.0515393518, 734959.4864814815, 734949.5842476852, 734959.0367476852, 734959.038125, 734959.0423032407, 734959.052025463, 734959.4603819444, 734959.4895023148, 734949.5819791667, 734959.0348958333, 734959.0390740741, 734959.0432407408, 734959.0515856481, 734959.4579976852, 734959.487175926]
values = [39, 68, 27, 57, 22, 33, 70, 19, 60, 53, 52, 33, 87, 63, 78, 34, 26, 42, 24, 97, 20, 1, 32, 60, 61, 48, 30, 48, 17]
dformat = mpl.dates.DateFormatter('%m-%d-%Y %H:%M:%S')
figure = plt.figure()
graph = figure.add_subplot(111)
graph.xaxis.set_major_formatter(dformat)
plt.xticks(rotation='vertical')
figure.subplots_adjust(bottom=.35)
graph.plot_date(dates,values)
graph.set_xticks(dates)
plt.show()
I have two questions:
Is there a way to create a spacing on the x-axis so that I can see the text and the datapoints clearly? This would result in a very long horizontal graph, but I will save this to an image file.
Relates to first question: to reduce the horizontal length of the graph, is there a way to compress ticks on the x-axis so that areas which have no data will be shortened?
For example, if we have three dates with values:
March 22 2013 23:11:04 55 March 22 2013 23:11:10 70 April 1 2013 10:43:56 5
Is it possible to condense the spaces between March 22 23:11:10 and April 1 2013 1-:43:56?