|
From: Florian L. <mai...@xg...> - 2005-05-16 16:44:58
|
Hello,
I've the following code:
def makeLinePlot(self, graph):
fig = Figure()
p = fig.add_subplot(111)
for label, line in graph.sourceReader:
p.plot(line, label=label)
print len(line)
p.legend(loc=0)
p.xaxis.set_ticklabels(graph.sourceReader.headers)
print graph.sourceReader.headers
print len(graph.sourceReader.headers)
canvas = FigureCanvas(fig)
canvas.print_figure(graph.name, dpi=graph.dpi)
On the console this generated this output:
15
15
15
15
15
15
15
15
15
15
15
['Jan 04', 'Feb 04', 'Mar 04', 'Apr 04', 'May 04', 'Jun 04', 'Jul 04', 'Aug
04', 'Sep 04', 'Oct 04', 'Nov 04', 'Dec 04', 'Jan 04', 'Feb 05', 'Mar 05']
15
So all data lists and the ticklabels lists are of equal length.
But the generated graph only shows the first 8 elements of the tick labels
(from "Jan 04" to "Aug 04"). The data is completely shown. Only ticklabels
are missing.
What is wrong there?
Thanks,
Florian
|
|
From: John H. <jdh...@ac...> - 2005-05-16 16:58:22
|
>>>>> "Florian" == Florian Lindner <mai...@xg...> writes:
Florian> So all data lists and the ticklabels lists are of equal
Florian> length.
Florian> But the generated graph only shows the first 8 elements
Florian> of the tick labels (from "Jan 04" to "Aug 04"). The data
Florian> is completely shown. Only ticklabels are missing.
Florian> What is wrong there?
It is not important that the datalists and tick labels are equal
length. What matters is for the tick locations and tick labels to be
equal length. You also need to call ax.set_xticks in addition to
ax.set_xticklabels.
But since you are working with dates, I think you'll have better luck
setting a custom tick locator and formatter, as described in
http:/matplotlib.sf.net/matplotlib.ticker.html,
http:/matplotlib.sf.net/matplotlib.dates.html, and
http:/matplotlib.sf.net/examples/date_demo1.py,
http:/matplotlib.sf.net/examples/date_demo2.py and chapter 5 the users
guide.
Florian> Thanks,
Florian> Florian
Florian> -------------------------------------------------------
Florian> This SF.Net email is sponsored by Oracle Space
Florian> Sweepstakes Want to be the first software developer in
Florian> space? Enter now for the Oracle Space Sweepstakes!
Florian> http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
Florian> _______________________________________________
Florian> Matplotlib-users mailing list
Florian> Mat...@li...
Florian> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|
|
From: Travis B. <td...@fa...> - 2005-05-16 17:51:35
|
Date ticking was a hassle for me to get used to, but I think the examples John pasted below and this will get you through: http://matplotlib.sourceforge.net/screenshots/finance_work2.py Travis On Mon, 16 May 2005 11:57:49 -0500, "John Hunter" <jdh...@ac...> said: > >>>>> "Florian" == Florian Lindner <mai...@xg...> writes: > > Florian> So all data lists and the ticklabels lists are of equal > Florian> length. > > Florian> But the generated graph only shows the first 8 elements > Florian> of the tick labels (from "Jan 04" to "Aug 04"). The data > Florian> is completely shown. Only ticklabels are missing. > > Florian> What is wrong there? > > It is not important that the datalists and tick labels are equal > length. What matters is for the tick locations and tick labels to be > equal length. You also need to call ax.set_xticks in addition to > ax.set_xticklabels. > > But since you are working with dates, I think you'll have better luck > setting a custom tick locator and formatter, as described in > http:/matplotlib.sf.net/matplotlib.ticker.html, > http:/matplotlib.sf.net/matplotlib.dates.html, and > http:/matplotlib.sf.net/examples/date_demo1.py, > http:/matplotlib.sf.net/examples/date_demo2.py and chapter 5 the users > guide. > > > > Florian> Thanks, > > Florian> Florian > > > Florian> ------------------------------------------------------- > Florian> This SF.Net email is sponsored by Oracle Space > Florian> Sweepstakes Want to be the first software developer in > Florian> space? Enter now for the Oracle Space Sweepstakes! > Florian> http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click > Florian> _______________________________________________ > Florian> Matplotlib-users mailing list > Florian> Mat...@li... > Florian> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > ------------------------------------------------------- > This SF.Net email is sponsored by Oracle Space Sweepstakes > Want to be the first software developer in space? > Enter now for the Oracle Space Sweepstakes! > http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Travis Brady td...@fa... |
|
From: Florian L. <mai...@xg...> - 2005-05-16 17:20:09
|
Am Montag, 16. Mai 2005 18:57 schrieb John Hunter: > >>>>> "Florian" =3D=3D Florian Lindner <mai...@xg...> writes: > > Florian> So all data lists and the ticklabels lists are of equal > Florian> length. > > Florian> But the generated graph only shows the first 8 elements > Florian> of the tick labels (from "Jan 04" to "Aug 04"). The data > Florian> is completely shown. Only ticklabels are missing. > > Florian> What is wrong there? > > It is not important that the datalists and tick labels are equal > length. What matters is for the tick locations and tick labels to be > equal length. You also need to call ax.set_xticks in addition to > ax.set_xticklabels. Ok, I've added: p.set_xticks(range(len(graph.sourceReader.headers))) Is it possible to change the angle of ticks? Right now they are overwriting= =20 each other. When I could change the angle to 45=B0 for example there would = be=20 enough space. > > But since you are working with dates, I think you'll have better luck > setting a custom tick locator and formatter, as described in > http:/matplotlib.sf.net/matplotlib.ticker.html, > http:/matplotlib.sf.net/matplotlib.dates.html, and > http:/matplotlib.sf.net/examples/date_demo1.py, > http:/matplotlib.sf.net/examples/date_demo2.py and chapter 5 the users > guide. Since I don't know in which format the input data will be I can't use=20 functions which treat them specifically as dates. Thanks, =46lorian |
|
From: John H. <jdh...@ac...> - 2005-05-16 17:26:53
|
>>>>> "Florian" =3D=3D Florian Lindner <mai...@xg...> writes:
Florian> Is it possible to change the angle of ticks? Right now
Florian> they are overwriting each other. When I could change the
Florian> angle to 45=B0 for example there would be enough space.
labels =3D ax.set_xticklabels(...)
for label in labels:
label.set_rotation(45)
JDH
|