python - Rotating part of xticks -



python - Rotating part of xticks -

on x-axis, display numbers (with no rotation) rotated names below each number. have next separately rotate names 'one', 'two' , 'three'.

plt.xticks([1,2,3], ['1\n one', '2\n two', '3\n three'], rotation=45]

you can place major , minor ticks @ same positions. here minimum example:

class="lang-py prettyprint-override">import pylab pl pl.clf() ax = pl.gca() ax.set_xticks([1, 2, 3]) ax.set_xticks([1, 2, 3], minor=true) ax.set_xticklabels(['one', 'two', 'three'], minor=true) pl.setp(ax.xaxis.get_minorticklabels(), rotation=-45) t in ax.get_xticklabels(minor=true): t.set_y(-0.03)

(with inspiration this answer.)

python matplotlib

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -