From: Bogdan M. <bog...@gm...> - 2004-07-23 18:59:37
|
Hello again, I've created some axes, and I'm trying to put some custom Ox tick labels on the axes. I would also like to have different alignments for each tick label. This is the code I'm using (with matplotlib.0.61.0a on Win32 with the WXAgg backend): self.axes.set_xticks( [0, 1, 2, 3 ]) th = self.axes.set_xticklabels( ['12:23:000', '+4s', '+8s', '+12s' ] ) th[ 0 ].set_horizontalalignment( 'left' ) th[ 1 ].set_horizontalalignment( 'center' ) th[ 2 ].set_horizontalalignment( 'center' ) th[ 3 ].set_horizontalalignment( 'right' ) But it seems that all the tick labels have the last set alignment (in this case 'right'). Is this a bug, or am I just missing something as usual? Thank you. -- Bogdan |
From: John H. <jdh...@ac...> - 2004-07-23 19:49:29
|
>>>>> "Bogdan" == Bogdan Marinescu <bog...@gm...> writes: Bogdan> Hello again, I've created some axes, and I'm trying to Bogdan> put some custom Ox tick labels on the axes. I would also Bogdan> like to have different alignments for each tick Bogdan> label. This is the code I'm using (with matplotlib.0.61.0a Bogdan> on Win32 with the WXAgg backend): Hi, I thought we had lost you to PyPlot :-) Egads, that was a tough one. Every once in a while when developing I'll make a temporary change in the src code for experimental purposes and forget to undo it. This is one of those cases. In matplotlib.axis.XAxis, on or around line 575, find the line that reads #tick = self._get_tick(major=True) tick = protoTick and replace it with tick = self._get_tick(major=True) The assignment 'tick = protoTick' was causing all ticks to share properties. FYI, matplotlib has a fairly general and extensible tick locator and formatter framework, which you can read about in http://matplotlib.sf.net/matplotlib.ticker.html and in the examples custom_ticker1.py, major_minor_demo1.py and major_minor_demo2.py in the matplotlib src distribution or at http://matplotlib.sf.net/examples. The set_ticks, set_ticklabels, etc, commands are just wrappers for these classes. JDH |
From: Bogdan M. <bog...@gm...> - 2004-07-23 20:34:46
|
Thank you, John. I thought I was lost to PyPlot too, but ... well, matplotlib is just too cool :) So I struggled a bit and I managed to get a print of the graph by first saving it to a file and then printing the file. It actually woks on wxPython 2.5.2.2, I don't expect it to work with 2.5.1.5. I imagine that some people will benefit from this code and I'd be more than happy to give my share to matplotlib. So please let me know how should I send my code. IF I should send it :) I'll do it tomorrow if everything is OK, I'm exhausted today. On Fri, 23 Jul 2004 14:25:31 -0500, John Hunter <jdh...@ac...> wrote: > >>>>> "Bogdan" == Bogdan Marinescu <bog...@gm...> writes: > > Bogdan> Hello again, I've created some axes, and I'm trying to > Bogdan> put some custom Ox tick labels on the axes. I would also > Bogdan> like to have different alignments for each tick > Bogdan> label. This is the code I'm using (with matplotlib.0.61.0a > Bogdan> on Win32 with the WXAgg backend): > > Hi, I thought we had lost you to PyPlot :-) > > Egads, that was a tough one. Every once in a while when developing > I'll make a temporary change in the src code for experimental purposes > and forget to undo it. This is one of those cases. In > matplotlib.axis.XAxis, on or around line 575, find the line that reads > > #tick = self._get_tick(major=True) > tick = protoTick > > and replace it with > > tick = self._get_tick(major=True) > > The assignment 'tick = protoTick' was causing all ticks to share > properties. > > FYI, matplotlib has a fairly general and extensible tick locator and > formatter framework, which you can read about in > http://matplotlib.sf.net/matplotlib.ticker.html and in the examples > custom_ticker1.py, major_minor_demo1.py and major_minor_demo2.py in > the matplotlib src distribution or at > http://matplotlib.sf.net/examples. The set_ticks, set_ticklabels, > etc, commands are just wrappers for these classes. > > JDH > > -- Bogdan |
From: John H. <jdh...@ac...> - 2004-07-25 20:56:04
|
>>>>> "Bogdan" == Bogdan Marinescu <bog...@gm...> writes: Bogdan> Thank you, John. I thought I was lost to PyPlot too, Bogdan> but ... well, matplotlib is just too cool :) So I Bogdan> struggled a bit and I managed to get a print of the graph Bogdan> by first saving it to a file and then printing the Bogdan> file. It actually woks on wxPython 2.5.2.2, I don't expect Bogdan> it to work with 2.5.1.5. I imagine that some people will Bogdan> benefit from this code and I'd be more than happy to give Bogdan> my share to matplotlib. So please let me know how should I Bogdan> send my code. IF I should send it :) I'll do it tomorrow Bogdan> if everything is OK, I'm exhausted today. Definitely send the code. If it's not too big, just post it to the list. Pasting in the code is better than attachments because the sourceforge archiver drops attachments (but be careful that the lines don't wrap). If the code is too long, you can send it to me and I'll include a link to it on the web site. Thanks, John |
From: Bogdan M. <bog...@gm...> - 2004-07-26 07:01:11
Attachments:
newwx.py
|
Hi John, I'm sending the code as an attachement, as it is 215 lines long and some of them could wrap. Some thoughts about the code: in order to test it just modify the definitions of IMAGE_FILE and (maybe) PRINT_DPI. Then start the program and use "print" and "preview" from the "file" menu. The preview doesn't look like the original plot (at least on the machines I tested it), and I don't know why. The colors seem to be twisted or something in the preview. If somebody has any clues about this, I'd be more than happy to know. However, this is only a preview problem, the print itself looks fine. Don't expect the code to run on the current "official" version of wxPython (2.5.1.5); download the 2.5.2.2 test release (or a more recent version) from http://starship.python.net/crew/robind/wxPython/daily/20040722/. Only tested on WinXP and Win2000 with the WXAgg backend, I don't know anything about the other platforms or backends, if someone else could test this it would be great. This could certainly be improved by telling the backend what wxDC it should use to draw the image on (thus skipping the save image/load image step), but so far I believe this is a good solution. John, I have some comments on the wx / wxAgg backends; I've been able to totally eliminate the very annoying flicker that I got when moving a window on a plot canvas. I guess that the dev list would be a better place for these comments, right? -- Bogdan |