From: John H. <jdh...@ac...> - 2005-04-07 03:47:17
|
>>>>> "jim" == jim <jl...@yv...> writes: jim> John: What I need to do is create drawings of windows (as in jim> plug holes in houses and let in light) with grid and other jim> options on the fly. jim> So what I need are the graphic primitives -- canvas, lines, jim> fills ... The output needs to be a graphic file. You probably want to be using matplotlib primitives. Assuming you have a matplotlib.axes.Axes (or Subplot) instance stored as "ax", The primitives are matplotlib.lines.Line2D - add with ax.add_line matplotlib.patches.Rectangle - add with ax.add_patch matplotlib.patches.Polygon - add with ax.add_patch matplotlib.patches.RegularPolygon - add with ax.add_patch matplotlib.patches.Circle - add with ax.add_patch matplotlib.patches.Text - add with ax.add_artist Ie, there are not too many mpl primitives, and using these will insulate you from changes in the mpl backend (renderer) api. The backend API is meant only for mpl developers. The classes referred to above are all part of the matplotlib Artist hierarchy. jim> I will go back and study the docs, but a suggestion of what jim> area to use would be most welcome. Or, of course, a jim> different module than matplotlib if that would be more jim> appropriate. To reiterate, there is one base class matplotlib.artist.Artist that all the objects that render into the figure derive from. From this, there are just a few derived classes to be aware of: Line2D, Patch, Text, and Collection. From these there are a few more derived classes (eg Patch and Collection have some specialized derived classes, Line2D and Text do not as of yet). Other Artists (including Figure, Axes, Legend, Table and so on) are simply composites of these primitive types. See the following class docs for more info: http://matplotlib.sourceforge.net/matplotlib.artist.html http://matplotlib.sourceforge.net/matplotlib.lines.html http://matplotlib.sourceforge.net/matplotlib.patches.html http://matplotlib.sourceforge.net/matplotlib.text.html http://matplotlib.sourceforge.net/matplotlib.collections.html In short, you should concentrate on building the primitive types you need rather than calling the renderer methods directly. The primitives will call the right renderer methods as necessary (as they do in matplotlib.lines, for example). Hope this helps, JDH |