Sometimes we are interested in plotting one curve but with several sets of tick values. For example, the curve represents observations at different time and locations. How to add two sets of tick values to the figure, one for the time and the other for the locations ? Here is one example using python and matplotlib, if the ticks values are in xaxis.
ax1=subplot(111);
plot(data);
#set the tick position
ax1.xaxis.tick_bottom();
#define the ticks
xticks(tick_range1, xtickval1 ,position=(0,0), fontsize=10)
# Make a second axes overlay ax1 by sharing the yaxis
ax2=twiny();
# put the tickvalues in the bottom
ax2.xaxis.tick_bottom()
#define the new ticks. The position of the ticks values is now different from that in ax1.
#this is to put the second set of tick values lower than the first set.
xticks(tick_range2, xtickval2 ,position=(0,-0.03), fontsize=10)
Aucun commentaire:
Enregistrer un commentaire