From: Jochen V. <vo...@se...> - 2004-11-19 11:40:30
|
Hello, I used matplotlib to create a graphical representation of the boot process of my Debian GNU/Linux system. The result can be found at http://seehuhn.de/comp/bootlog.html and especially in the (2400x1500 sized) picture http://seehuhn.de/comp/bootlog2.png I have a question about matplotlib usage: I would like the picture to have vertical grid lines at positions 1, 2, 3, 4, ..., not horizonzal grid lines. On the horizontal x-Axis I would like to see labels at positions 0, 5, 10, 15, ... and I would like to get rid of the labels on the y-Axis. Is this possible? How do I do it? All the best, Jochen --=20 http://seehuhn.de/ |
From: John H. <jdh...@ac...> - 2004-11-19 15:11:10
|
>>>>> "Jochen" == Jochen Voss <vo...@se...> writes: Jochen> Hello, I used matplotlib to create a graphical Jochen> representation of the boot process of my Debian GNU/Linux Jochen> system. The result can be found at Jochen> http://seehuhn.de/comp/bootlog.html Jochen> and especially in the (2400x1500 sized) picture Jochen> http://seehuhn.de/comp/bootlog2.png Very nice - you manage to pack a lot of information into the graph. Edward Tufte would be proud! It's nice to have folks stress testing matplotlib Jochen> I have a question about matplotlib usage: * I would like the picture to have vertical grid lines at positions 1, 2, 3, 4, ..., On the horizontal x-Axis I would like to see labels at positions 0, 5, 10, 15, ... The best way to do this would be to use minor ticks on 1,2,3,4,etc and major ticks on 0,5,10,15 - the grids occur at the locations of the ticks, and you can customize how you want the ticks labeled. See examples/major_minor_demo1.py and the use of the MultipleLocator. The Multiple locator places ticks at multiples of some base. For you minor ticks you would use MultipleLocator(1) and for your major ticks MultipleLocator(1). The labels for the minor ticks are off by default which is what you want, though you can customize this. See http://matplotlib.sf.net/matplotlib.ticker.html for more info. * not horizonzal grid lines. The ax.xaxis.grid and ax.yaxis.grid functions can be used to selectively turn on and off the grids for the respective axes. The signature is def grid(self, b, which='major'): where b is a boolean. You can use this to control gridding for the major and minor ticks on a per-axis basis. So ax.yaxis.grid(False) selectively turns off the grids for the y axis major tick grid lines. The minor grids are off by default. You can turn them on, eg with ax.xaxis.grid(True, which='minor') * and I would like to get rid of the labels on the y-Axis. Is this possible? ax.set_yticklabels('') See also the functions xticks and yticks in the matlab interface for easy customization of tick locations and labels. Cheers, JDH |
From: John H. <jdh...@ac...> - 2004-11-19 15:58:43
|
>>>>> "Jochen" == Jochen Voss <vo...@se...> writes: Jochen> Hello, I used matplotlib to create a graphical Jochen> representation of the boot process of my Debian GNU/Linux Jochen> system. The result can be found at Jochen> http://seehuhn.de/comp/bootlog.html Jochen> and especially in the (2400x1500 sized) picture Jochen> http://seehuhn.de/comp/bootlog2.png After looking again at your plot, particularly the rectangle parts with text labels, it occurs to me that it would be nice to have a general purpose class for this (rectangular boxes with text labels). The class matplotlib.tables.Cell strives for this, but is not feature complete. What would be nice would be to be able to specify the location of the text with respect to the box, with horizontal and vertical alignment. This wouldn't be too hard, since text already has these alignment flags with respect to an x,y location ( eg http://matplotlib.sf.net/screenshots.html#align_text ). For full control, one would want to be able to specify the location of x,y with respect to the rectangle (left, center, bottom, right, etc) *and* the alignment of the text with respect to the x,y location, so that one could have -------------------- | | | centered | | | -------------------- -------------------- | | | | to-the-right | | -------------------- -------------------- |top-left-under | | | | | -------------------- top-left-over -------------------- | | | | | | -------------------- and so on..... All the components are in place to make this relatively easy from a layout persepctive. One just has to plug them together and make a nice, intuitive interface. JDH |
From: Jochen V. <vo...@se...> - 2004-11-19 16:38:49
|
Hello John, thanks a lot for your help. My picture is improving. But one problem is left: the script from matplotlib.matlab import * from matplotlib.ticker import MultipleLocator subplot(211) ax=3Dgca() ax.xaxis.set_minor_locator(MultipleLocator(1)) ax.xaxis.set_major_locator(MultipleLocator(5)) ax.xaxis.grid(True, which=3D"minor") ax.yaxis.grid(False) semilogy([1,2,3,4,5,6,7,8,9,10,11],[1,2,3,4,5,6,7,8,9,10,11],basey=3D2) show() has vertical grid lines ONLY on the minor ticks, which looks silly. How do I get regularly spaced grid lines here? All the best, Jochen --=20 http://seehuhn.de/ |
From: John H. <jdh...@ac...> - 2004-11-19 16:53:47
|
>>>>> "Jochen" == Jochen Voss <vo...@se...> writes: Jochen> has vertical grid lines ONLY on the minor ticks, which Jochen> looks silly. How do I get regularly spaced grid lines Jochen> here? This is a consequence of the fact that the ticker skips minor ticks which coincide with major ticks. I am not sure this is the right behavior, but was implemented to avoid other problems (overlapping gridlines, for example, with anti-aliasing produces undesirable results). All you need to do is turn both major and minor grids on ax.xaxis.grid(True, which="minor") ax.xaxis.grid(True, which="major") Should work.... JDH |