python - How to get a bigger font size for x-axis tick labels in scipy-generated dedrogram? -
with following imports:
import matplotlib mpl scipy.cluster.hierarchy import dendrogram
i set font size globally (based on this other stack overflow answer):
mpl.rcparams.update({'font.size': 20})
then create dendrogram following (where m
matrix created elsewhere):
dendrogram(m)
then show plot with:
mpl.pyplot.show()
the y-axis tick labels 20 points expected. however, x-axis tick labels tiny, smaller 20 points. seems matplotlib automatically scaling down font size fit density of data despite font size settings above. case when zoom in , there plenty of room show larger font.
how can make x-axis ticks use larger font size?
you can axes.tick_params()
method:
import matplotlib mpl mpl.use('agg') import matplotlib.pyplot plt scipy.cluster.hierarchy import dendrogram, linkage import numpy n = 20 n = numpy.random.normal(size=(n, 2)) z = linkage(n) # implicit interface dendrogram(z) ax = plt.gca() ax.tick_params(axis='x', which='major', labelsize=15) ax.tick_params(axis='y', which='major', labelsize=8) plt.savefig('t.png') # explicit interface fig = plt.figure() ax = fig.add_subplot(1, 1, 1) dendrogram(z, ax=ax) ax.tick_params(axis='x', which='major', labelsize=15) ax.tick_params(axis='y', which='major', labelsize=8) fig.savefig('t.png')
Comments
Post a Comment