2010/4/11 tomislav_ma...@gmx.com <tomislav.ma...@gmx.com>: > can someone help me to plot a polygon in matplotlib? > I have been reading about the axes.patches.Polygon class and I have defined > the > Polygon object that has a preset lw and points. How do I plot it?
Here http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.add_artist maybe helps? > I'm confused because the Axes documentation states that this class holds > most of > the figure objects like Rectangle, Line2D, and then the website states that > the Line2D > is a return object from the plt.plot() invocation. What if I create my own > set of Rectangle > (Polygon) objects and want to create a list of them and plot them? afaik, the artist, or whatever, is retured to make its properties adjustable later. > Also, I'm using this sequence of commands to work in OO mode interactively > (just to learn) but when I execute plt.draw() no figure appears. > > import numpy as np > import matplotlib.pyplot as plt > > myFig = plt.figure() > > myAx = myFig.add_axes() # I have tried myFig.add_subplot(1,1,1) but it > didn't help > > x = np.arange(0,np.pi, 0.01) > > myAx.plot (x, np.sin(x)) > > plt.draw() # nothing happens As your oo Figure is not registered to the plt module, since you created it via api, this should be normal. Maybe have a look at http://matplotlib.sourceforge.net/examples/user_interfaces/index.html , I think you have to embed your api-created Figure in a widget manager of your choice. > These commands are executed within an interactive ipython session but if I > start ipython > > with ipython -pylab, plt.draw() draws a figure I can see. I'm running Arch > linux and Openbox > > as a window manager, the system is 64 bit. I think you can use Tk via the Tkinter Python package. On linux I heard it's looking a bit weird, but as a starting points it's easy enough. But maybe try also the other widget managers, like Gtk. There are certainly some people around which have more knowledge on Gtk and so on than me having with Tkinter. hth, Friedrich ------------------------------------------------------------------------------ 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