From: Simon F. <sim...@a-...> - 2010-07-16 15:11:41
|
Hello List. I'm trying to plot a confusion matrix and I got this far: http://paste.pocoo.org/show/238332/ Basically what I still want to do is get the ticklabels from the bottom to the top, have every ticklabel shown and start showing them from the first not from the second. I have experimented with this for a while now and don't have all the code states at hand anymore but basically at several points some of the above worked but the others didn't or something else (like the axis length) broke. Best Simon |
From: Friedrich R. <fri...@gm...> - 2010-07-17 20:50:01
|
2010/7/16 Simon Friedberger <sim...@a-...>: > Hello List. > > I'm trying to plot a confusion matrix and I got this far: > http://paste.pocoo.org/show/238332/ > > Basically what I still want to do is get the ticklabels from the bottom > to the top, have every ticklabel shown and start showing them from the > first not from the second. Maybe try to use axes.set_xticks() first, see http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_xticks . Your code on pocoo is messed up with whitespace. Is that intentional? Friedrich |
From: Simon F. <sim...@a-...> - 2010-07-18 16:02:39
|
On 22:49 Sat 17.07.10, Friedrich Romstedt wrote: > Maybe try to use axes.set_xticks() first, see > http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_xticks > . I know about that but couldn't find any useful way. Could you be more specific? > Your code on pocoo is messed up with whitespace. Is that intentional? Messed up? It looks all good to me. Regards Simon |
From: Friedrich R. <fri...@gm...> - 2010-07-18 16:32:36
|
2010/7/18 Simon Friedberger <sim...@a-...>: > On 22:49 Sat 17.07.10, Friedrich Romstedt wrote: >> Maybe try to use axes.set_xticks() first, see >> http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_xticks >> . > I know about that but couldn't find any useful way. Could you be more > specific? Try to add: ax.set_xticks(range(0, 10)) ax.set_yticks(range(0, 10)) before the imshow call. For some reason it must happen before the imshow call and not after, else the yscaling will change (I don't understand this). >> Your code on pocoo is messed up with whitespace. Is that intentional? > Messed up? It looks all good to me. Sorry, but there is plenty of whitespace at the end of each line when I copy-paste the code, even in raw format. hth you, Friedrich |
From: Simon F. <sim...@a-...> - 2010-07-28 22:30:20
|
On 18:32 Sun 18.07.10, Friedrich Romstedt wrote: > Try to add: > ax.set_xticks(range(0, 10)) > ax.set_yticks(range(0, 10)) > > before the imshow call. > > For some reason it must happen before the imshow call and not after, > else the yscaling will change (I don't understand this). Thanks for this tip. Apparently there is a necessary order for some calls. Is this documented anywhere? It seems quite problematic. Also I have now finished my confusion matrix program: http://paste.pocoo.org/show/242834/ Comments on the code would be very welcome. If people like it maybe it could be included in the examples. I think it's a relatively common usecase. Regards Simon |
From: Matthieu B. <mat...@gm...> - 2010-07-29 06:45:06
|
Hi, In scikits.learn, there is a confusion matrix and in the samples, there are several plots (scikit-learn.sf.net). Matthieu 2010/7/16 Simon Friedberger <sim...@a-...>: > Hello List. > > I'm trying to plot a confusion matrix and I got this far: > http://paste.pocoo.org/show/238332/ > > Basically what I still want to do is get the ticklabels from the bottom > to the top, have every ticklabel shown and start showing them from the > first not from the second. > > I have experimented with this for a while now and don't have all the > code states at hand anymore but basically at several points some of the > above worked but the others didn't or something else (like the axis > length) broke. > > Best > Simon > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Information System Engineer, Ph.D. Blog: http://matt.eifelle.com LinkedIn: http://www.linkedin.com/in/matthieubrucher |
From: Friedrich R. <fri...@gm...> - 2010-07-29 07:26:40
|
2010/7/29 Simon Friedberger <sim...@a-...>: > Also I have now finished my confusion matrix program: > http://paste.pocoo.org/show/242834/ > Comments on the code would be very welcome. I think you can make use of axis.set_label_position('top') axis.set_ticks_position('none') Friedrich |
From: Simon F. <sim...@a-...> - 2010-07-29 08:46:49
|
For some magical reason when I set the ticks_position to none, setting the label_position to 'top' is ignored. Did you try this? Is it another command arrangement thing? On 09:26 Thu 29.07.10, Friedrich Romstedt wrote: > axis.set_label_position('top') > axis.set_ticks_position('none') |
From: Friedrich R. <fri...@gm...> - 2010-07-31 07:29:15
|
2010/7/29 Simon Friedberger <sim...@a-...>: > For some magical reason when I set the ticks_position to none, setting > the label_position to 'top' is ignored. > Did you try this? Is it another command arrangement thing? > > On 09:26 Thu 29.07.10, Friedrich Romstedt wrote: >> axis.set_label_position('top') >> axis.set_ticks_position('none') No, I didn't try, it was just a collection of commands, but I was wrong: .set_label_position() refers to the axis label, this is the single string labeling all the ticks with their "labels", e.g. "This is $x$ axis.". What you will want to use is .set_tick_params(top=True, labeltop=False, labelbottom=False) . (But I didn't try this either. :-) set_ticks_position() is just a shorthand for .set_tick_params(). Friedrich |
From: Simon F. <sim...@a-...> - 2010-08-06 14:00:20
|
On 09:29 Sat 31.07.10, Friedrich Romstedt wrote: > What you will want to use is .set_tick_params(top=True, > labeltop=False, labelbottom=False) . That worked indeed but I have uncovered another problem. It is about the positioning of the rotated labels. The code is here: http://paste.pocoo.org/show/246870/ Note that in line 36 I had already remarked about the hack I used. Now I noticed that if the labels have different lengths rotating them gives different positions. What I really want to do is rotate about the bottom of the labels. Can that be done? Regards Simon |
From: Simon F. <sim...@a-...> - 2010-08-08 09:18:50
|
On 16:00 Fri 06.08.10, Simon Friedberger wrote: > It is about the positioning of the rotated labels. > The code is here: > http://paste.pocoo.org/show/246870/ > > Note that in line 36 I had already remarked about the hack I used. Now I > noticed that if the labels have different lengths rotating them gives > different positions. What I really want to do is rotate about the bottom > of the labels. Can that be done? I have found a solution. I'm not sure if it's good or intended but the following works: for label in xax.get_ticklabels(): label.set_rotation(45) label.set_horizontalalignment('left') Please comment. Apart from that it's here for people who look for a solution to the same question. Best Simon |
From: Friedrich R. <fri...@gm...> - 2010-08-09 01:03:39
Attachments:
simon.py
|
2010/8/8 Simon Friedberger <sim...@a-...>: > I have found a solution. I'm not sure if it's good or intended but the > following works: > > for label in xax.get_ticklabels(): > label.set_rotation(45) > label.set_horizontalalignment('left') This is fully intended. Maybe you can compare with the version attached, I believe my version should have some minor improvement (the labels are anchored all with the baseline's leftmost point at the center of the grid cell). I have not tried your version, though. You got rid of the +0.4 with your solution I believe? Also, for the previous pocoo version still online there, I had a problem with the "superduperverylonglabel". It was shiftet to the left. What is understandable from the point of view that matplotlib anchored the labels' center point at x + 0.4. > Please comment. Apart from that it's here for people who look for a > solution to the same question. Yes, I agree fully, but have been busy the past few days :-) Friedrich P.S.: You can also try http://matplotlib.sourceforge.net/examples/pylab_examples/alignment_test.html , I believe there was some other manual around also covering the baseline option, but I cannot find it now. |
From: John H. <jd...@gm...> - 2010-08-09 04:37:39
|
On Sun, Aug 8, 2010 at 8:03 PM, Friedrich Romstedt <fri...@gm...> wrote: > Yes, I agree fully, but have been busy the past few days :-) > > Friedrich > > P.S.: You can also try > http://matplotlib.sourceforge.net/examples/pylab_examples/alignment_test.html > , I believe there was some other manual around also covering the > baseline option, but I cannot find it now. > The "codex" option on the search page helps with this; you can easily search for "codex baseline":: * the default search page: http://matplotlib.sourceforge.net/search.html * what is codex?: http://matplotlib.sourceforge.net/faq/howto_faq.html#search-examples * an example using "codex baseline": http://matplotlib.sourceforge.net/search.html?q=codex+baseline Basically, you go to the default mpl homepage or any sub-page, and from there, click the "Search" link, and then enter "codex YOURPHRASE" where codex stands for "code example" and will return all code examples containing your phrase. JDH |
From: Friedrich R. <fri...@gm...> - 2010-08-09 14:14:16
|
2010/8/9 John Hunter <jd...@gm...>: > On Sun, Aug 8, 2010 at 8:03 PM, Friedrich Romstedt > <fri...@gm...> wrote: >> P.S.: You can also try >> http://matplotlib.sourceforge.net/examples/pylab_examples/alignment_test.html >> , I believe there was some other manual around also covering the >> baseline option, but I cannot find it now. > > The "codex" option on the search page helps with this; you can easily > search for "codex baseline":: > > * the default search page: http://matplotlib.sourceforge.net/search.html > > * what is codex?: > http://matplotlib.sourceforge.net/faq/howto_faq.html#search-examples > > * an example using "codex baseline": > http://matplotlib.sourceforge.net/search.html?q=codex+baseline Thanks, that will be very useful. Actually the page I was looking for was: http://matplotlib.sourceforge.net/examples/pylab_examples/demo_text_rotation_mode.html?highlight=codex%20baseline So far, Friedrich |