SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Chris.Barker <Chr...@no...> - 2011年11月23日 17:52:44
Hi Folks,
I've got some drawing to do (for a web app). I don't need all the MPL 
machinery, but I do need a high quality, fast, renderer.
Other options:
 - The python bindings to GD seem to not really being maintained
 - PyCairo is a pain to install, and not fast for Python (doesn't know 
about numpy arrays of points, for instance)
 - Kiva appears to be quite enmeshed with ETS, and thus a bit of trick 
to install (at least without EPD or PythonXY or something)
So I thought I'd give MPL's AGG wrappers a try. I've managed to get 
things working, but I do have a couple questions:
1) are there docs somewhere? What I've found is very sparse, and doc 
strings are minimal -- though I've got the source, so only so much or a 
complaint.
2) It looks like the AGG renderers take floats for almost everything -- 
makes sense, with anti-aliasing and sub-pixel rendering. But is it 
float32 or float64 internally? It seems either will work, but I'm going 
for maximum performance, so I'd like to use the native format.
Testing drawing a polygon, I'm a bit confused about GraphicsContext vs 
the renderer. If I do:
gc = GraphicsContextBase()
transform = Affine2D() # default unit transform
## draw the polygon:
## create a path for a polygon:
points = np.array(((10,10),(10,190),(150,100),(290,10),(10,10)),np.float64)
p = Path(points)
gc.set_linewidth(4)
gc.set_alpha(0.75)
fill_color = (0.0, 1.0, 0.0)
line_color = (1.0, 0.0, 0.0)
#gc._rgb = line_color
gc.set_foreground(line_color)
Canvas.draw_path(gc, p, transform, fill_color)
I get a green polygon with a red border, like I'd expect. However:
Why is the outline color set in the GraphicsContext, but the fill color 
passed in to the draw_path call? Or am I doing that wrong?
Thanks for input,
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Chris.Barker <Chr...@no...> - 2011年11月23日 17:56:29
On 11/23/11 9:52 AM, Chris.Barker wrote:
> I've got some drawing to do (for a web app). I don't need all the MPL
> machinery, but I do need a high quality, fast, renderer.
One more question. I see:
 def draw_markers(self, *kl, **kw):
 # for filtering to work with rastrization, methods needs to be 
wrapped.
 # maybe there is better way to do it.
 return self._renderer.draw_markers(*kl, **kw)
What do I pass in to this function?
Thanks,
 -Chris
> Other options:
>
> - The python bindings to GD seem to not really being maintained
>
> - PyCairo is a pain to install, and not fast for Python (doesn't know
> about numpy arrays of points, for instance)
>
> - Kiva appears to be quite enmeshed with ETS, and thus a bit of trick
> to install (at least without EPD or PythonXY or something)
>
>
> So I thought I'd give MPL's AGG wrappers a try. I've managed to get
> things working, but I do have a couple questions:
>
> 1) are there docs somewhere? What I've found is very sparse, and doc
> strings are minimal -- though I've got the source, so only so much or a
> complaint.
>
> 2) It looks like the AGG renderers take floats for almost everything --
> makes sense, with anti-aliasing and sub-pixel rendering. But is it
> float32 or float64 internally? It seems either will work, but I'm going
> for maximum performance, so I'd like to use the native format.
>
>
> Testing drawing a polygon, I'm a bit confused about GraphicsContext vs
> the renderer. If I do:
>
> gc = GraphicsContextBase()
> transform = Affine2D() # default unit transform
>
> ## draw the polygon:
> ## create a path for a polygon:
> points = np.array(((10,10),(10,190),(150,100),(290,10),(10,10)),np.float64)
>
> p = Path(points)
>
> gc.set_linewidth(4)
> gc.set_alpha(0.75)
>
> fill_color = (0.0, 1.0, 0.0)
> line_color = (1.0, 0.0, 0.0)
>
> #gc._rgb = line_color
> gc.set_foreground(line_color)
>
> Canvas.draw_path(gc, p, transform, fill_color)
>
> I get a green polygon with a red border, like I'd expect. However:
>
> Why is the outline color set in the GraphicsContext, but the fill color
> passed in to the draw_path call? Or am I doing that wrong?
>
>
> Thanks for input,
>
> -Chris
>
>
>
>
>
>
>
>
>
>
>
>
>
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Friedrich R. <fri...@gm...> - 2011年11月23日 18:14:03
2011年11月23日 Chris.Barker <Chr...@no...>:
> I've got some drawing to do (for a web app). I don't need all the MPL
> machinery, but I do need a high quality, fast, renderer.
http://www.effbot.org/zone/aggdraw-index.htm
http://www.effbot.org/imagingbook/imagedraw.htm
Don't know if this suffices your needs.
Friedrich
From: Benjamin R. <ben...@ou...> - 2011年11月23日 18:39:03
On Wednesday, November 23, 2011, Chris.Barker <Chr...@no...> wrote:
> Hi Folks,
>
> I've got some drawing to do (for a web app). I don't need all the MPL
> machinery, but I do need a high quality, fast, renderer.
>
> Other options:
>
> - The python bindings to GD seem to not really being maintained
>
> - PyCairo is a pain to install, and not fast for Python (doesn't know
> about numpy arrays of points, for instance)
>
> - Kiva appears to be quite enmeshed with ETS, and thus a bit of trick
> to install (at least without EPD or PythonXY or something)
>
>
> So I thought I'd give MPL's AGG wrappers a try. I've managed to get
> things working, but I do have a couple questions:
>
> 1) are there docs somewhere? What I've found is very sparse, and doc
> strings are minimal -- though I've got the source, so only so much or a
> complaint.
>
> 2) It looks like the AGG renderers take floats for almost everything --
> makes sense, with anti-aliasing and sub-pixel rendering. But is it
> float32 or float64 internally? It seems either will work, but I'm going
> for maximum performance, so I'd like to use the native format.
>
>
> Testing drawing a polygon, I'm a bit confused about GraphicsContext vs
> the renderer. If I do:
>
> gc = GraphicsContextBase()
> transform = Affine2D() # default unit transform
>
> ## draw the polygon:
> ## create a path for a polygon:
> points =
np.array(((10,10),(10,190),(150,100),(290,10),(10,10)),np.float64)
>
> p = Path(points)
>
> gc.set_linewidth(4)
> gc.set_alpha(0.75)
>
> fill_color = (0.0, 1.0, 0.0)
> line_color = (1.0, 0.0, 0.0)
>
> #gc._rgb = line_color
> gc.set_foreground(line_color)
>
> Canvas.draw_path(gc, p, transform, fill_color)
>
> I get a green polygon with a red border, like I'd expect. However:
>
> Why is the outline color set in the GraphicsContext, but the fill color
> passed in to the draw_path call? Or am I doing that wrong?
>
>
> Thanks for input,
>
> -Chris
>
>
There is an HTML5 backend, supposedly. Don't know how well documented it
is, though.
Ben Root
From: Chris.Barker <Chr...@no...> - 2011年11月23日 20:39:51
On 11/23/11 10:38 AM, Benjamin Root wrote:
> On Wednesday, November 23, 2011, Chris.Barker <Chr...@no...
> <mailto:Chr...@no...>> wrote:
> > Hi Folks,
> >
> > I've got some drawing to do (for a web app). I don't need all the MPL
> > machinery, but I do need a high quality, fast, renderer.
> There is an HTML5 backend, supposedly. Don't know how well documented
> it is, though.
Hmm -- coll idea -- I'll look into that at some point. However, as I 
don't need the MPL machinerey, but just the renderer, I'm not sure it 
would buy me much.
And I'm not sure I can:
a) count on html 5 on all browsers we need to support
or
b) get the drawing performance I want if I have to push all the data to 
the client to draw.
But something to keep an eye on, thanks.
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Chris B. <Chr...@no...> - 2011年11月27日 01:22:32
On 11/23/11 10:13 AM, Friedrich Romstedt wrote:
> 2011年11月23日 Chris.Barker<Chr...@no...>:
>> I've got some drawing to do (for a web app). I don't need all the MPL
>> machinery, but I do need a high quality, fast, renderer.
>
> http://www.effbot.org/zone/aggdraw-index.htm
I've been wondering about that -- it doesn't look terribly maintained -- 
no updates for a long time, and I'm concerned about performance 99 if 
you are drawing something simple, but with lot's of points, all that 
conversion from numpy types to python type to C types is going to be an 
issue.
> http://www.effbot.org/imagingbook/imagedraw.htm
this is definitely slow for what I'm doing.
Thanks,
 -Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /