Hi
I’m plotting data associated with dates.
I have two problems.
The first one is that the xlabel “date” is displayed despite that haven’t set Matplotlib to do so.
My code is the following one :
fig = plt.figure(1)
title_to_display=str("Entropy, Kullback-LeiblerL, symmetric KL and resistor KL from %s to %s"%(IP_list_RTT[i][0].split("_")[1],IP_list_RTT[i][0].split("_")[2]))
ax_1 = fig.add_subplot(2,2,1)
ax_1.plot(dates_RTT,data_RTT,'r-')
ax_2 = twinx()
ax_2.plot(dates_distances,entropy_list)
ax_2.plot(dates_distances,kullback_leibler_list)
ax_2.plot(dates_distances,symmetric_kullback_leibler_list)
ax_2.plot(dates_distances,resistor_average_kullback_leibler_list)
ax_2.yaxis.tick_right()
title(title_to_display,fontsize=size_font_title)
ax_1.grid(True)
ax_1.xaxis.set_major_formatter(formatter_1)
ax_2.xaxis.set_major_formatter(formatter_2)
labels_x1 = ax_1.get_xticklabels()
labels_x2 = ax_2.get_xticklabels()
setp(labels_x1, rotation=rotation_x_label, fontsize=size_font_x_label)
setp(labels_x2, rotation=rotation_x_label, fontsize=size_font_x_label)
All the variables relatives to the display (rotation_x_label,size_font_x_label,size_font_title) are defined before.
If I add xlabel(“tutut”), I just get “tutut” print over the two previous “date” (one for ax_1 and one for ax_2).
It also looks like there is two x tick labels formatted displayed.
I tried to define two formatters with one empty and one “normal” and assign them to the two different axes that I’m using with something like this :
formatter_1 = DateFormatter(’’)
formatter_2 = DateFormatter(’%H-%M-%S’)
and then :
ax_1.xaxis.set_major_formatter(formatter_1)
ax_2.xaxis.set_major_formatter(formatter_2)
But it doesn’t work.
If the empty formatter is the first one, it looks that both x tick labels are displayed at the same time (just as before). And if the empty formatter is the second, none of the x tick labels are displayed.
Thanks in advance for the help.
Regards.
Johan Mazel