Re: [Matplotlib-users] Documentation suggestions (longish post)
On Sun, Apr 18, 2010 at 12:10 AM, Gary Ruben wrote: > I've been helping a fairly new Python user (an astronomer using > numpy/scipy/matplotlib) in my office get up to speed with matplotlib and > thought I'd pass on a couple of small thoughts about the documentation > which we think would make life clearer for new users. I'm putting this > out for discussion, because it may be totally off-the-mark. On the other > hand, it may point to some easy changes to make things clearer for new > users. > > First, I think that a new user, presented with the mpl homepage, reads > the intro on that page, then perhaps clicks through to either the > pyplot, examples, or gallery pages. They may take example code from > examples or gallery and modify them for their own plots, but they will > at some point be referencing the pyplot page (this is also my > most-visited page on the site). > > The matplotlib.pyplot page would really benefit from a few introductory > paragraphs or even a single sentence with a link to the relevant section > in the docs, explaining what the relationship of pyplot is to the other > parts of mpl. > Specifically, I think confusion arises because the explanation about the > stateful nature of the pyplot interface is (I think) first mentioned at > the start of the pyplot tutorial page, and is perhaps not emphasized > enough. It may also be worth stating somewhere in the front-page mpl > intro that it is recommended that new users do the pyplot tutorial. > > The signatures that a new user sees are full of *args and **kwargs which > is confusing for the new user. There is an explanation in the coding > guide so perhaps another paragraph or sentence+link to this would help, > but I think it's probably not a good idea to be directing new users into > the coding guide. I know about the history of this and I gather that > most or all of the args are actually tabulated in the documentation now, > but new users don't necessarily know what *args and **kwargs mean. I > think there's still a general lack of consistency in the pyplot docs > related to this. Some docstrings have the call signature shown, with > default values shown. It's confusing that some kwargs have explicit > descriptions and appear in the call signature whereas others are just > "additional kwargs". This split seems to me to be exposing the > underlying implementation of the function to the user. I don't know > whether there is logic behind this. > > The final area of confusion is to do with jargon, as this seems to creep > into examples and list discussions. The introduction to the Artist > Tutorial is quite useful for understanding mpl's plotting model. > However, for the new user, it is pretty much impenetrable due to the > jargon and references to other libraries and coding concepts that a new > user doesn't need to know. I think a gentler description of mpl's > plotting model in the introduction or in a standalone small chapter > would be helpful for new users. The documentation exists to help the users, so if you're having trouble with them, the docs probably *are* lacking. I know I'm not likely to get to this any time soon however, so patches are welcome. :) If you're interested, the docs live here: http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/doc/ Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Problem with figure sizes using Qt4Agg
On Tue, Apr 13, 2010 at 8:14 PM, Gökhan Sever wrote: > Hello, > > Could someone confirm me if there is any malfunctioning using these simple > figure functions? > > plt.figure(figsize=(2,3)) > > plt.figure(figsize=(5,6)) > > plt.figure(figsize=(9,15)) > > plt.figure(figsize=(19,5)) > > For some reason I can't get Qt4Agg creating last two figures in specified > sizes. (WXAgg works fine.) > > matplotlib.__version__ > '1.0.svn' > > matplotlib.__revision__ > '$Revision: 8226 $' > > from PyQt4 import QtCore > QtCore.PYQT_VERSION_STR > '4.7' I can reproduce this behavior with a pure pyqt4 example with no mpl code, see below. I asked for advice on the pyqt mailing list. import sys from PyQt4 import QtCore, QtGui class Test(QtGui.QWidget): def __init__(self, width, height): QtGui.QWidget.__init__(self) #self.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) print 'Central widget should have width=%d, height=%d' %(width, height) self._width = width self._height = height def sizeHint(self): return QtCore.QSize(self._width, self._height) app = QtGui.QApplication([]) m = QtGui.QMainWindow() c = Test(1000, 700) m.setCentralWidget(c) m.show() s = c.size() print 'but central widget has width=%d, height=%d'% (s.width(), s.height()) sys.exit(app.exec_()) -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Problem with figure sizes using Qt4Agg
On Sun, Apr 18, 2010 at 11:47 AM, Darren Dale wrote: > On Tue, Apr 13, 2010 at 8:14 PM, Gökhan Sever > wrote: > > Hello, > > > > Could someone confirm me if there is any malfunctioning using these > simple > > figure functions? > > > > plt.figure(figsize=(2,3)) > > > > plt.figure(figsize=(5,6)) > > > > plt.figure(figsize=(9,15)) > > > > plt.figure(figsize=(19,5)) > > > > For some reason I can't get Qt4Agg creating last two figures in specified > > sizes. (WXAgg works fine.) > > > > matplotlib.__version__ > > '1.0.svn' > > > > matplotlib.__revision__ > > '$Revision: 8226 $' > > > > from PyQt4 import QtCore > > QtCore.PYQT_VERSION_STR > > '4.7' > > I can reproduce this behavior with a pure pyqt4 example with no mpl > code, see below. I asked for advice on the pyqt mailing list. > > import sys > from PyQt4 import QtCore, QtGui > > class Test(QtGui.QWidget): > > def __init__(self, width, height): > QtGui.QWidget.__init__(self) > #self.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) > print 'Central widget should have width=%d, height=%d' %(width, > height) > self._width = width > self._height = height > > def sizeHint(self): > return QtCore.QSize(self._width, self._height) > > app = QtGui.QApplication([]) > m = QtGui.QMainWindow() > c = Test(1000, 700) > m.setCentralWidget(c) > m.show() > s = c.size() > print 'but central widget has width=%d, height=%d'% (s.width(), s.height()) > sys.exit(app.exec_()) > Same here with your sample: Central widget should have width=1000, height=700 but central widget has width=960, height=600 I resorted to WXAgg for the time being. Waiting for some updates till I hear a resolution. The annoying part is when I created a plot using specified width and height Qt4Agg doesn't follow these dimensions as in this case and resulting savefig(file.pdf) produces wrongly sized file unless I manually extend the figure area and re-issue a savefig afterwards. -- Gökhan -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Question about mathtext
Hi! I am using matplotlib 0.99.0 under windows xp. I tried the following: ax.text(.96,.80,r'$P \perp Q$',fontsize=18,horizontalalignment='right',verticalalignment='top',transform=ax.transAxes,color='black') and get the following error: (However, in figure labels, symbols using mathtext, such as theta seem to work fine...) Thanks, William TypeError: cannot return std::string from Unicode object File "C:\mytripleaxisproject\trunk\eclipse\src\utilities\bfo_film_fig2.py", line 301, in film110() File "C:\mytripleaxisproject\trunk\eclipse\src\utilities\bfo_film_fig2.py", line 157, in film110 plt.show() File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_qt4.py", line 63, in show manager.window.show() File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_qt4.py", line 168, in resizeEvent self.draw() File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 130, in draw FigureCanvasAgg.draw(self) File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line 314, in draw self.figure.draw(self.renderer) File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper draw(artist, renderer, *kl) File "C:\Python25\Lib\site-packages\matplotlib\figure.py", line 774, in draw for a in self.axes: a.draw(renderer) File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper draw(artist, renderer, *kl) File "C:\Python25\Lib\site-packages\matplotlib\axes.py", line 1721, in draw a.draw(renderer) File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 515, in draw bbox, info = self._get_layout(renderer) File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 279, in _get_layout clean_line, self._fontproperties, ismath=ismath) File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line 156, in get_text_width_height_descent self.mathtext_parser.parse(s, self.dpi, prop) File "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", line 2810, in parse box = self._parser.parse(s, font_output, fontsize, dpi) File "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", line 2259, in parse self._expression.parseString(s) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 1048, in parseString loc, tokens = self._parse( instring, 0 ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 981, in _parseCache value = self._parseNoCache( instring, loc, doActions, callPreParse ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 924, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 2559, in parseImpl return self.expr._parse( instring, loc, doActions, callPreParse=False ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 981, in _parseCache value = self._parseNoCache( instring, loc, doActions, callPreParse ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 924, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 2307, in parseImpl loc, exprtokens = e._parse( instring, loc, doActions ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 981, in _parseCache value = self._parseNoCache( instring, loc, doActions, callPreParse ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 924, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 2672, in parseImpl loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 981, in _parseCache value = self._parseNoCache( instring, loc, doActions, callPreParse ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 924, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 2307, in parseImpl loc, exprtokens = e._parse( instring, loc, doActions ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 981, in _parseCache value = self._parseNoCache( instring, loc, doActions, callPreParse ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 924, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 2756, in parseImpl loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 981, in _parseCache value = self._parseNoCache( instring, loc, doActions, callPreParse ) File "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", line 924, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "C:\Python25\Lib\site-packages\matplotli
[Matplotlib-users] install from svn on Linux not working for me
My goal is to just get the lastest svn version of matplotlib, or, if not that, just the 0.99 version, up and working on my Linux (Intrepid Ibex) computer. I checked it matplotlib out from svn fine, and then, as per the webpage, did: > cd matplotlib > python setup.py install and that resulted in a very large amount of errors. I'll post them at the bottom of this message, since there are many lines. I previously had 0.98.x installed, via the Ubuntu repositories, but I have uninstalled it. My version is: Linux ubuntu 2.6.27-7-generic #1 SMP Fri Oct 24 06:40:41 UTC 2008 x86_64 GNU/Linux Any help is appreciated. Thank you, Che Errors (starting from a few lines before): creating build/temp.linux-x86_64-2.5/src creating build/temp.linux-x86_64-2.5/CXX gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/lib/python2.5/site-packages/numpy/core/include -I/usr/local/include -I/usr/include -I. -I/usr/lib/python2.5/site-packages/numpy/core/include/freetype2 -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I./freetype2 -I/usr/include/python2.5 -c src/ft2font.cpp -o build/temp.linux-x86_64-2.5/src/ft2font.o cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ In file included from ./CXX/Extensions.hxx:37, from src/ft2font.h:4, from src/ft2font.cpp:1: ./CXX/WrapPython.h:58:20: error: Python.h: No such file or directory In file included from src/ft2font.cpp:1: src/ft2font.h:13:22: error: ft2build.h: No such file or directory src/ft2font.h:14:10: error: #include expects "FILENAME" or src/ft2font.h:15:10: error: #include expects "FILENAME" or src/ft2font.h:16:10: error: #include expects "FILENAME" or src/ft2font.h:17:10: error: #include expects "FILENAME" or src/ft2font.h:18:10: error: #include expects "FILENAME" or In file included from /usr/lib/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14, from src/ft2font.cpp:5: /usr/lib/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:100:2: error: #error Must use Python with unicode enabled. In file included from ./CXX/Python3/Exception.hxx:45, from ./CXX/Python3/Objects.hxx:45, from ./CXX/Python3/Extensions.hxx:52, from ./CXX/Extensions.hxx:42, from src/ft2font.h:4, from src/ft2font.cpp:1: ./CXX/Python3/IndirectPythonInterface.hxx:50: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:51: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:52: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:53: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:55: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:56: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:57: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:58: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:59: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:60: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:61: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:62: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:63: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:64: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:65: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:66: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:67: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:68: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:69: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:70: error: expected constructor, destructor, or type conversion before ‘*’ token ./CXX/Python3/IndirectPythonInterface.hxx:7
Re: [Matplotlib-users] Turning off minor grids on log scaled plot
On Sunday 18 April 2010 00:52:57 Gökhan Sever wrote: > Hello, > > Let say we have a figure created by: > > plt.plot(range(100)) > > On WX backend plt.grid(1) or key "G" responds finely for turning on/off the > grid lines. However when I log-scale both axes then plt.grid(1 or 0) or "G" > doesn't respond on minor grid lines. > > Is there a way to control this behavior? > > Thanks. Hi Gökhan, I can confirm your findings and I hope my attached patch (against current svn) solves this problem. In the axes.grid the boolean 'b' was set to 'True' if the kwarg 'which' was suplied, because it was part of the **kwargs and so always b was True in the axis (e.g. ax.xaxis). Now I get a grid on the minor-ticks by calling: ax.grid(True, which="majorminor") and remove the the minortick-grid lines / all grid lines by calling ax.grid(False, which="minor") ax.grid(False, which="majorminor") Kind regards, Matthias Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (revision 8242) +++ lib/matplotlib/axes.py (working copy) @@ -1839,19 +1839,20 @@ self._axisbelow = b @docstring.dedent_interpd -def grid(self, b=None, **kwargs): +def grid(self, b=None, which='major', **kwargs): """ call signature:: grid(self, b=None, **kwargs) -Set the axes grids on or off; *b* is a boolean - +Set the axes grids on or off; *b* is a boolean. Use *which* = +'major' | 'minor' to set the grid for major or minor ticks. + If *b* is *None* and ``len(kwargs)==0``, toggle the grid state. If *kwargs* are supplied, it is assumed that you want a grid and *b* is thus set to *True* -*kawrgs* are used to set the grid line properties, eg:: +*kwargs* are used to set the grid line properties, eg:: ax.grid(color='r', linestyle='-', linewidth=2) @@ -1860,8 +1861,8 @@ %(Line2D)s """ if len(kwargs): b = True -self.xaxis.grid(b, **kwargs) -self.yaxis.grid(b, **kwargs) +self.xaxis.grid(b, which=which, **kwargs) +self.yaxis.grid(b, which=which, **kwargs) def ticklabel_format(self, **kwargs): """ -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users