I use autofmt_xdate to draw long labels along the x axis in a readable way. The problem is that when I want to combine different subheadings, the X axis marking of the other subplots disappears, which I donβt understand for the leftmost subheading in the figure below (two rows high). Is there a way to prevent autofmt_xdate from extinguishing other X axis labels? Or is there another way to rotate labels? As you can see, I experimented with xticks and βrotateβ, but the results were not satisfactory because the labels were rotated around their center, which led to random marking.
Script that creates the graph below:
from matplotlib import pyplot as plt from numpy import arange import numpy from matplotlib import rc rc("figure",figsize=(15,10)) #rc('figure.subplot',bottom=0.1,hspace=0.1) rc("legend",fontsize=16) fig = plt.figure() Test_Data = numpy.random.normal(size=20) fig = plt.figure() Dimension = (2,3) plt.subplot2grid(Dimension, (0,0),rowspan=2) plt.plot(Test_Data) plt.subplot2grid(Dimension, (0,1),colspan=2) for i,j in zip(Test_Data,arange(len(Test_Data))): plt.bar(i,j) plt.legend(arange(len(Test_Data))) plt.subplot2grid(Dimension, (1,1),colspan=2) xticks = [r"%s (%i)" % (a,b) for a,b in zip(Test_Data,Test_Data)] plt.xticks(arange(len(Test_Data)),xticks) fig.autofmt_xdate() plt.ylabel(r'$Some Latex Formula/Divided by some Latex Formula$',fontsize=14) plt.plot(Test_Data) #plt.setp(plt.xticks()[1],rotation=30) plt.tight_layout() #plt.show()

python matplotlib
langohrschnauze
source share