From: jim <jl...@yv...> - 2005-04-07 02:51:11
|
Running this script gives the results below #! /usr/bin/env python from matplotlib.backends.backend_agg import RendererAgg from matplotlib.transforms import Value dpi = Value(100.0) o = RendererAgg(100,200, dpi) gc = o.new_gc() gc.set_foreground('k') face = (1,1,1) gc.set_linewidth(1) o.draw_rectangle(gc, face, 0,0, 100,200) o.draw_lines(gc, (1,100,1), (1,100,200)) o._renderer.write_png("test.png") #*** Results from running the above **************** # J:\>python test4.py # Traceback (most recent call last): # File "test4.py", line 16, in ? # o.draw_lines(gc, x, y) # IndexError: Unexpected SeqBase<T> length. # # J:\> #**************************************************** Running in on linux-gentoo 2004 runs just fine. Gives the expected output file. My windows setup is win2k, python2.4 I loaded numeric and numarray. Gives the same results in either case. I have Borland5.5 installed have build an extension with it. Other than that have several other nonstock modules installed. Running it on win98 with python 2.4 gives a different error, but much the same effect. Thanks in advance Jim Hurlburt Yakima, WA |
From: John H. <jdh...@ac...> - 2005-04-07 03:12:52
|
>>>>> "jim" == jim <jl...@yv...> writes: jim> Running this script gives the results below #! /usr/bin/env jim> python jim> from matplotlib.backends.backend_agg import RendererAgg from jim> matplotlib.transforms import Value I know there are examples in the pdf user's guide discussing how to use the backend renderer directly, and these are meant mostly to be helpful to matplotlib developers. Unfortunately, the guide has lagged behind the current development state. The backend renderer API is in a transition state right now as we try to introduce some new methods to solve some old problems. In particular, the draw_lines method that you are experiencing problems with has recently had a change in its call signature. These changes have been discussed at some length recently on the matplotlib-devel list. If you are interested, you might want to browse the matplotlib-devel archives and/or join the mailing list; see for example http://sourceforge.net/mailarchive/forum.php?thread_id=6938045&forum_id=36187 . Thanks for reporting this discrepancy -- in the near term the backend API shouldn't be used on the user side. If there is something you want to do but can't in the current API let me know. As for the platform specific differences you report, my first guess is that the matplotlib versions may not be the same. I wouldn't expect platform specific differences in the backend API for the same version. JDH |
From: jim <jl...@yv...> - 2005-04-07 03:29:17
|
John: What I need to do is create drawings of windows (as in plug holes in houses and let in light) with grid and other options on the fly. So what I need are the graphic primitives -- canvas, lines, fills ... The output needs to be a graphic file. I will go back and study the docs, but a suggestion of what area to use would be most welcome. Or, of course, a different module than matplotlib if that would be more appropriate. Thanks, Jim On Wednesday 06 April 2005 08:13 pm, you wrote: > >>>>> "jim" == jim <jl...@yv...> writes: > > jim> Running this script gives the results below #! /usr/bin/env > jim> python > > jim> from matplotlib.backends.backend_agg import RendererAgg from > jim> matplotlib.transforms import Value > > I know there are examples in the pdf user's guide discussing how to > use the backend renderer directly, and these are meant mostly to be > helpful to matplotlib developers. Unfortunately, the guide has lagged > behind the current development state. The backend renderer API is in > a transition state right now as we try to introduce some new methods > to solve some old problems. In particular, the draw_lines method that > you are experiencing problems with has recently had a change in its > call signature. > > These changes have been discussed at some length recently on the > matplotlib-devel list. If you are interested, you might want to > browse the matplotlib-devel archives and/or join the mailing list; see > for example > http://sourceforge.net/mailarchive/forum.php?thread_id=6938045&forum_id=36187 . > > Thanks for reporting this discrepancy -- in the near term the backend > API shouldn't be used on the user side. If there is something you > want to do but can't in the current API let me know. > > As for the platform specific differences you report, my first guess is > that the matplotlib versions may not be the same. I wouldn't expect > platform specific differences in the backend API for the same version. > > JDH > > > > |
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 |