I posed the question below back in Nov, but never received a response. Thought I'd try again, as I really do need this kind of plot, and I don't want to leave the world of matplotlib, which has improved my efficiency greatly in plotting.
Thanks,
Suresh
···
---------- Forwarded message ----------
I have a figure with two subplots as below. However, everything breaks
when I try to rotate the x-labels as indicated in the two commented-out
lines. I obtain a small empty plot embedded in a large empty plot with no
x-labels and no legend either. I got this code from the tutorial; it
works perfectly fine for the same data/commands if only using a single
main plot.
pylab.subplot(211)
pylab.plot(historicalScore05, label='Score 2005')
pylab.plot(historialNum05, label='Num 2006')
pylab.setp(pylab.gca(), xticklabels=[])
pylab.ylabel('Score 2')
pylab.title('Historical Statistics')
pylab.legend(loc='upper left')
pylab.subplot(212)
pylab.plot(historicalScore06, label='Score 06')
pylab.plot(historicalNum06, label='Num 06')
pylab.xticks(dates)
#xlabels = pylab.axes().get_xticklabels()
#pylab.setp(xlabels, 'rotation', 90)
pylab.xlabel('Player')
pylab.ylabel('Score 1')
pylab.legend(loc='upper left')
Any idea what is wrong?
numpy-1.0
matplotlib-0.87.7
Thanks,
Suresh
Ooop, sorry I corrupted the pylab.xticks() line in the second part when editing. Should read:
pylab.subplot(211)
pylab.plot(historicalScore05, label='Score 2005')
pylab.plot(historialNum05, label='Num 2006')
pylab.setp(pylab.gca(), xticklabels=[])
pylab.ylabel('Score 2')
pylab.title('Historical Statistics')
pylab.legend(loc='upper left')
pylab.subplot(212)
pylab.plot(historicalScore06, label='Score 06')
pylab.plot(historicalNum06, label='Num 06')
pylab.xticks(pylab.arange(numDatapoints),xLabels)
#xlabels = pylab.axes().get_xticklabels()
#pylab.setp(xlabels, 'rotation', 90)
pylab.xlabel('Player')
pylab.ylabel('Score 1')
pylab.legend(loc='upper left')
Using:
numpy-1.0
matplotlib-0.87.7
The result is a small empty plot (plot frame only: no labels, ticks, data, legend) within an empty plot of subplot 212 (no data, no legend, but yes for ticks and axis titles).
Thanks,
Suresh
···
On Wed, 28 Feb 2007, Suresh Pillai wrote:
I posed the question below back in Nov, but never received a response.
Thought I'd try again, as I really do need this kind of plot, and I don't
want to leave the world of matplotlib, which has improved my efficiency
greatly in plotting.
Thanks,
Suresh
Ooop, sorry I corrupted the pylab.xticks() line in the second part when
editing. Should read:
pylab.subplot(211)
pylab.plot(historicalScore05, label='Score 2005')
pylab.plot(historialNum05, label='Num 2006')
pylab.setp(pylab.gca(), xticklabels=[])
pylab.ylabel('Score 2')
pylab.title('Historical Statistics')
pylab.legend(loc='upper left')
pylab.subplot(212)
pylab.plot(historicalScore06, label='Score 06')
pylab.plot(historicalNum06, label='Num 06')
pylab.xticks(pylab.arange(numDatapoints),xLabels)
#xlabels = pylab.axes().get_xticklabels()
That line right there, you are creating a new set of axes, and getting its
xticklabels, rather than getting the xticklabels of the existing axes. Try:
xlabels = pylab.gca().get_xticklabels()
#pylab.setp(xlabels, 'rotation', 90)
pylab.xlabel('Player')
pylab.ylabel('Score 1')
pylab.legend(loc='upper left')
Darren
···
On Wednesday 28 February 2007 02:59:08 pm Suresh Pillai wrote: