Ich habe Probleme beim Ändern der Hilfsstrichbeschriftungseigenschaften in einem Diagramm mit Doppelachsen. Ich möchte, dass der Text klein und in einer anderen Schriftart als der Standard ist. Ich fand einen Weg, der gut funktionierte, bis ich es mit twiny() versuchte. Die zweite Achse reagiert nicht auf die Anweisungen zur Tick-Formatierung, wie Sie in der Abbildung sehen können. Fehle ich etwas Entscheidendes oder gibt es einen Fehler in Matplotlib?Anpassen der Hilfsstrichsgröße auf den Zwillingsachsen
Ubuntu 12.04, Python 2.7.3, matplotlib 1.1.1rc
#!/usr/bin/env python
# coding: utf-8
from matplotlib import pyplot as p
from numpy import sin, cos, arange
x = arange(0, 10, .01)
for plotnum in range(1,5):
p.subplot(2, 2, plotnum)
ax1 = p.gca()
p.plot(sin(x),x)
ax2 = p.twiny()
p.plot(cos(x)+plotnum,x, 'g--')
# Set size all tick labels
# Works for first axes (lower x-ticks) and can also change font
for tickset in [ax1.xaxis.get_major_ticks()]:
[(tick.label.set_fontsize(plotnum*4), tick.label.set_fontname('ubuntu mono')) for tick in tickset]
# Does not work for second axes (upper x-ticks)
for tickset in [ax2.xaxis.get_major_ticks()]:
[(tick.label.set_fontsize(plotnum*2), tick.label.set_fontname('ubuntu mono')) for tick in tickset]
# This works, but doesn't allow changing font
#ax2.tick_params(axis='both', which='major', labelsize=plotnum*2)
Hier ist ein Bild:
Edit: feste falsche Einrücken von tick-Wechsel Linien
Edit: Eingefügt Bild (Thriveth)