SourceForge logo
SourceForge logo
Menu

matplotlib-devel — matplotlib developers

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
(1)
Nov
(33)
Dec
(20)
2004 Jan
(7)
Feb
(44)
Mar
(51)
Apr
(43)
May
(43)
Jun
(36)
Jul
(61)
Aug
(44)
Sep
(25)
Oct
(82)
Nov
(97)
Dec
(47)
2005 Jan
(77)
Feb
(143)
Mar
(42)
Apr
(31)
May
(93)
Jun
(93)
Jul
(35)
Aug
(78)
Sep
(56)
Oct
(44)
Nov
(72)
Dec
(75)
2006 Jan
(116)
Feb
(99)
Mar
(181)
Apr
(171)
May
(112)
Jun
(86)
Jul
(91)
Aug
(111)
Sep
(77)
Oct
(72)
Nov
(57)
Dec
(51)
2007 Jan
(64)
Feb
(116)
Mar
(70)
Apr
(74)
May
(53)
Jun
(40)
Jul
(519)
Aug
(151)
Sep
(132)
Oct
(74)
Nov
(282)
Dec
(190)
2008 Jan
(141)
Feb
(67)
Mar
(69)
Apr
(96)
May
(227)
Jun
(404)
Jul
(399)
Aug
(96)
Sep
(120)
Oct
(205)
Nov
(126)
Dec
(261)
2009 Jan
(136)
Feb
(136)
Mar
(119)
Apr
(124)
May
(155)
Jun
(98)
Jul
(136)
Aug
(292)
Sep
(174)
Oct
(126)
Nov
(126)
Dec
(79)
2010 Jan
(109)
Feb
(83)
Mar
(139)
Apr
(91)
May
(79)
Jun
(164)
Jul
(184)
Aug
(146)
Sep
(163)
Oct
(128)
Nov
(70)
Dec
(73)
2011 Jan
(235)
Feb
(165)
Mar
(147)
Apr
(86)
May
(74)
Jun
(118)
Jul
(65)
Aug
(75)
Sep
(162)
Oct
(94)
Nov
(48)
Dec
(44)
2012 Jan
(49)
Feb
(40)
Mar
(88)
Apr
(35)
May
(52)
Jun
(69)
Jul
(90)
Aug
(123)
Sep
(112)
Oct
(120)
Nov
(105)
Dec
(116)
2013 Jan
(76)
Feb
(26)
Mar
(78)
Apr
(43)
May
(61)
Jun
(53)
Jul
(147)
Aug
(85)
Sep
(83)
Oct
(122)
Nov
(18)
Dec
(27)
2014 Jan
(58)
Feb
(25)
Mar
(49)
Apr
(17)
May
(29)
Jun
(39)
Jul
(53)
Aug
(52)
Sep
(35)
Oct
(47)
Nov
(110)
Dec
(27)
2015 Jan
(50)
Feb
(93)
Mar
(96)
Apr
(30)
May
(55)
Jun
(83)
Jul
(44)
Aug
(8)
Sep
(5)
Oct
Nov
(1)
Dec
(1)
2016 Jan
Feb
Mar
(1)
Apr
May
Jun
(2)
Jul
Aug
(3)
Sep
(1)
Oct
(3)
Nov
Dec
2017 Jan
Feb
(5)
Mar
Apr
May
Jun
Jul
(3)
Aug
Sep
(7)
Oct
Nov
Dec
2018 Jan
Feb
Mar
Apr
May
Jun
Jul
(2)
Aug
Sep
Oct
Nov
Dec
S M T W T F S

1
2
3
4
5
6
7
8
(3)
9
(5)
10
(8)
11
12
(4)
13
14
15
(1)
16
(6)
17
(4)
18
(7)
19
(3)
20
21
22
(2)
23
24
25
26
(1)
27
(1)
28
(1)
29
(3)
30
(2)
31



Showing results of 51

<< < 1 2 3 > >> (Page 2 of 3)
From: John H. <jdh...@ac...> - 2004年03月16日 14:05:16
>>>>> "Martin" == Martin Kuemmel <mku...@es...> writes:
 Martin> Hi John, I dont know whether you are the person to write
 Martin> to, but I simply try. I am trying to install matplotlib
 Martin> on:
 Martin> SunOS st13 5.8 Generic_108528-21 sun4u sparc
 Martin> SUNW,Sun-Blade-1500
 Martin> with gcc 3.3.2.
 Martin> In principle it works, and with the PS-backend it gives
 Martin> results. I would like to install the agg-backend, but did
 Martin> not manage to do so. I just installed the
 Martin> freetype2-library, and to include it at its position I
 Martin> changed the code in 'setupext.py', module
 Martin> 'add_agg_flags(module)', line 94 to;
 Martin> module.include_dirs.extend(
 Martin> ['/ecfsoft/pyraf1.1/include/freetype2',] )
 Martin> module.include_dirs.extend( ['/ecfsoft/pyraf1.1/include',]
 Martin> )
 Martin> i am still not at home, and I get the error messages:
 Martin> Text relocation remains referenced against symbol offset
 Martin> in file <unknown> 0x40
 Martin> /ecfsoft/pyraf1.1/lib/libz.a(deflate.o) <unknown> 0x4c
 Martin> /ecfsoft/pyraf1.1/lib/libz.a(deflate.o) <unknown> 0x58
 Martin> /ecfsoft/pyraf1.1/lib/libz.a(deflate.o)
 Martin> It seems not to include the libz correctly, but this
 Martin> library exists also at '/ecfsoft/pyraf1.1/include' and
 Martin> '/ecfsoft/pyraf1.1/lib'.
 Martin> What can I do?
 Martin> Cheers and thanks in advance, Martin
 Martin> P.S.: Please forward this mail to the appropriate person,
 Martin> or give me its email address
Hi Martin,
We are very interested in getting a build that works properly under
Solaris so thanks for writing and offering to be the crash test dummy.
I CCd this email to the matplotlib development list since some folks
there know a bit about solaris. You may want to consider joining the
user or development mailing list for future questions -
http://sourceforge.net/mail/?group_id=80706
I suggest you try working with the latest matplotlib snapshot
http://nitace.bsd.uchicago.edu:8080/files/share/matplotlib-0.52c.tar.gz
which has a somewhat improved setupext.py (it also includes basic
image support with the imshow command). Usually to get freetype you
need the dir that includes ft2build.h and the freetype2 include dir in
your include_path.
But it looks like you are getting a link error rather than an include
error. I just posted
 "Text relocation remains referenced against symbol offset" 
into google and got this result
http://mailman.cs.uchicago.edu/pipermail/swig/2002-April/004435.html.
That post suggests you need the linker flags -Wl,-G
Search google groups with the same error message and you'll get lots
of threads that look helpful.
When you get this working if you can post a modified setupext.py as
well as any additional dependencies and build instructions, that would
be great.
JDH
From: John H. <jdh...@ac...> - 2004年03月16日 13:24:52
On OS X 10.3, I can run TkAgg fine, interactive works great from the
prompt, etc. However, when I on the figure window to move it or click
on a navigation button etc, I get a "SetFrontProcess failed, -606"
message and the desired action does not happen. I am running under
X11, launching python from an xterm.
Do you get this Andrew? Any ideas?
JDH
From: John H. <jdh...@ac...> - 2004年03月16日 12:44:55
>>>>> "Andrew" == Andrew Straw <str...@as...> writes:
 Andrew> 2 points:
 Andrew> 1) Is there any reason why the Patch class doesn't have
 Andrew> get_xdata() and get_ydata() methods? 1b) If not, can we
 Andrew> add them and let Axes.add_patch(patch) call
 Andrew> "self.xaxis.datalim.update(patch.get_xdata())" ?
I removed this one day when I was trying to improve the painfully slow
pcolor code. The way patches were getting their xlimits was slow.
After spending some time with the profiler, I opted to set the axes
limits manually for scatter and pcolor rather than pay the additional
performance hit in add_patch. This makes the code a little more
difficult to maintain.
Perhaps better than get_xdata is get_xlim. What is the natural xdata
for a circle characterized by a center and radius? xlim is clear. I
added this for Polygon and modified the fill command to use it, and
will add it to the other patch commands and use it in add_patch in due
time. Or feel free to take the lead :-)
 Andrew> 2) I think there's still a Polygon facecolor bug. John, I
 Andrew> thought you fixed the Polygon facecolor bug -- my
 Andrew> patches.py code matches the bugfix you emailed the list,
 Andrew> but I still don't get the facecolor with the PS, GTK or
 Andrew> Agg backends.
The problem was that you didn't set fill=True in the Polygon
constructor. I added this and it works great. Here is my fill_demo
code - if you have something more impressive for the examples dir send
it along.
 from matplotlib.matlab import *
 t = arange(0.0, 1.01, 0.01)
 s = sin(2*2*pi*t)
 fill(t, s*exp(-5*t), 'r')
 grid(True)
 show()
Changes are in CVS.
Thanks!
JDH
From: Andrew S. <str...@as...> - 2004年03月16日 07:44:42
Attachments: fill_patch.txt.gz
G'day!
I've implemented a mostly-matlab-compatible "fill" command. I attach 
it for your pleasure and hopeful inclusion into matplotlib. (This is 
an extension of our previous email discussion and involved me going and 
using matlab for a bit to get a feel for their API.)
2 points:
1) Is there any reason why the Patch class doesn't have get_xdata() and 
get_ydata() methods?
1b) If not, can we add them and let Axes.add_patch(patch) call 
"self.xaxis.datalim.update(patch.get_xdata())" ?
2) I think there's still a Polygon facecolor bug. John, I thought you 
fixed the Polygon facecolor bug -- my patches.py code matches the 
bugfix you emailed the list, but I still don't get the facecolor with 
the PS, GTK or Agg backends.
Cheers!
Andrew
From: Andrew S. <str...@as...> - 2004年03月16日 03:27:51
On Tuesday, March 16, 2004, at 02:28 AM, John Hunter wrote:
> I've added image support in CVS along the lines discussed last week.
Great! A quick test shows that the demos work fine over here.
A quick note:
I had to add the following files to my CVS checkout from the tarball 
you provided. Could you add these to the CVS distribution? (If it's 
not SF's CVS servers being flakey?)
src/_image.h
src/_image.cpp
matplotlib/image.py
postinstall.py
From: John H. <jdh...@ac...> - 2004年03月15日 16:20:30
I've added image support in CVS along the lines discussed last week.
Currently only array loading (floats) is supported with
 imshow(X)
 
 If X is MxN, assume luminance (grayscale)
 If X is MxNx3, assume RGB
 If X is MxNx4, assume RGBA
but I'll work on adding PNG and colormaps in the
not-too-distant-future, as well as supporting more pixel formats. You
must use one of the *Agg backends. I'll add some helper methods to
make the scaled image data accessible by GTK and WX in the near
future.
See examples/image_demo.py.
It would also be nice to have a "frompil" method that could load the
image from a pil instance to get all the pil loaders for free. I
don't know how hard this would be.
You can set the interpolation method and whether or not aspect ratio
is preserved with
 im = imshow(A)
 im.set_aspect('preserve') # free is default; not constrained
 im.set_interpolation('bicubic') # bilinear default; see image module for others
You can also set the data extent of the image if you want to plot
lines, etc over your image. See examples/image_demo2.py. Currently
data extent with aspect ratio preserved is broken.
After playing around with some examples, there are a few things that
have become higher priorities.
 * update navigation controls. The asymmetric x and y zooms don't
 make a lot of sense for images. I plan to write a new toolbar with
 symmetric zooms, "hand" pan, and zoom to rectangle as discussed
 before. I'll try and write this in a way that the various GUI
 backends can subclass without too much additional work,
 * figure resize - on GTK and Tk at least, the ability to resize the
 figure is too limited. TkAgg, for example, always preserves the
 figure aspect ratio and GTK won't let you get smaller than the
 initial dimensions. It would be nice to allow more freedom here.
Let me know how it goes... Here's a snapshot or the sdist:
http://nitace.bsd.uchicago.edu:8080/files/share/matplotlib-0.52c.tar.gz
JDH
From: John H. <jdh...@ac...> - 2004年03月12日 22:13:46
>>>>> "Paul" == Paul Barrett <ba...@st...> writes:
 Paul> Just to make sure that I have this straight, the Text class
 Paul> should look like this:
 Paul> def __init__(self, ..., font, ...): ...
Yep
 Paul> If so, do you planning on changing get_fontxxxx() for
 Paul> get_font()?
No. you should have a get_font, an also get_fontxxxx that forwards
the call to the font object for backwards compatability.
 Paul> I should be able to do most of it.
Awesome! 
JDH
From: Paul B. <ba...@st...> - 2004年03月12日 20:17:35
John Hunter wrote:
> 
> I think font handling should be factored out of the Text class into a
> dedicated class. 
> 
> class Font:
> 
> pass
> 
> class Text(dpi, bbox, font, etc...):
> pass
Just to make sure that I have this straight, the Text class should look like this:
 def __init__(self, ..., font, ...):
 ...
 self._color = color
 self._text = text
 self._verticalalignment = verticalalignment
 self._horizontalalignment = horizontalalignment
 self._rotation = rotation
 self._font = font
instead of this:
 def __init__(self, ...):
 ...
 self._color = color
 self._text = text
 self._verticalalignment = verticalalignment
 self._horizontalalignment = horizontalalignment
 self._rotation = rotation
 self._fontname = fontname
 self._fontsize = fontsize
 self._fontweight = fontweight
 self._fontangle = fontangle
If so, do you planning on changing get_fontxxxx() for get_font()?
> 
> For user API compatibility, the critical thing is to preserve the
> getters and setters of Text, since the following is legal code
> 
> t = title('hi mom', fontname='Courier', fontsize=12)
> 
> which calls text.set_fontname and text.fontsize under the hood.
> 
> But the setters and getters can just forward the call to the new font
> instance as necessary.
OK.
> Vis-a-vis backends:
> 
> PS: As far as the finder algorithm is concerned, it would be nice if
> it was sufficiently generic that backend_ps could use it too. If
> you define an API that the algorithm needs vis-a-vis font
> properties, we modify the AFM and FT2Font classes to provide
> these.
Yes, this is my intention.
> Division of labor: if you want to make the required changes to
> text.Text, ttf_font_finder and (optionally) matplotlibrc I'm all for
> it. Once you have a prototype, I can help with all the text
> instantiators if you like, or you can do this too. Whichever way, I
> can definitely help with the backend ports once the above issues are
> resolved.
I should be able to do most of it.
 -- Paul
-- 
Paul Barrett, PhD Space Telescope Science Institute
Phone: 410-338-4475 ESS/Science Software Branch
FAX: 410-338-4767 Baltimore, MD 21218
From: John H. <jdh...@ac...> - 2004年03月12日 18:59:37
>>>>> "Paul" == Paul Barrett <ba...@st...> writes:
 Paul> As a final suggestion, we could have the Text object
 Paul> initialize the fontfamily attribute to a sans-serif font
 Paul> list, e.g. the one given above, since that seems to be a
 Paul> popular font family for many users.
I think all of the suggestions are good ones. I wasn't aware of the
CSS standards, but GTK (which provided the matplotlib font model) is
very close to it, including the use of xxlarge, etc.
 Paul> Please let me know what you think about this suggestion and
 Paul> if you have any changes to the design.
I think font handling should be factored out of the Text class into a
dedicated class. 
class Font:
 pass
class Text(dpi, bbox, font, etc...):
 pass
AFAIK, noone is directly instantiating Text instances in their code so
I don't think we'll have many API complaints. Then the respective
font finders (ttf and afm) can use the font instance in combination
with the CSS algorithm to find the fonts. 
This won't be too hard on the backends since most of them are already
using the font finders to get the ttf or afm filenames, so most of
these changes will be insulated except for changing the arguments of a
few functional calls. The major overhaul will be in matplotlib.text
and in the classes that instantiate text (Axis, Axes, Figure). I like
the idea of using relative sizes in all these classes.
For user API compatibility, the critical thing is to preserve the
getters and setters of Text, since the following is legal code
 t = title('hi mom', fontname='Courier', fontsize=12)
which calls text.set_fontname and text.fontsize under the hood.
But the setters and getters can just forward the call to the new font
instance as necessary.
Vis-a-vis backends:
 GTKAgg, Agg, TkAgg, GD, Paint: no problems here as they all use
 ttf_font_finder
 PS: As far as the finder algorithm is concerned, it would be nice if
 it was sufficiently generic that backend_ps could use it too. If
 you define an API that the algorithm needs vis-a-vis font
 properties, we modify the AFM and FT2Font classes to provide
 these.
 GTK: I think with minor changes we can make GTK play nicely with any
 ttf font on the system. I have to do a little more research.
 If not, the GTK font setup is so close to the CSS one that I can
 do the mapping pretty easily.
 WX: There is a standard set of WX fonts. I'm not sure how to map the
 generic ideas you put forth to the concrete fonts wx knows about,
 other than extending the fontnames dictionary to handle as many
 of the typical font names as possible and/or having users set the
 wx fontnames in matplotlibrc.
 
 It would also help to provide some helper functions which map
 numeric font weights to one of normal|bold|heavy|etc and the
 string font sizes to points (eg 'medium'->12pt) for the backends
 that don't know about these newfangled options.
 That way in backend_wx we could do
 s = font.get_weight_as_string()
 weight = self.fontweights[s] # this dict already exists in WX and GTK
 size = font.get_size_in_points()
 ...etc...
 In addition, Jeremy has indicated an interest in implementing
 WXAgg backend, which would get the new font handling for free.
Division of labor: if you want to make the required changes to
text.Text, ttf_font_finder and (optionally) matplotlibrc I'm all for
it. Once you have a prototype, I can help with all the text
instantiators if you like, or you can do this too. Whichever way, I
can definitely help with the backend ports once the above issues are
resolved.
I've already been planning to refactor the backend text API, that
would have required a font instance anyway. For all the other
attributes (lines, rectangles, etc), the backends don't know about the
matplotlib objects. eg, we say draw_line(x1,y1, x2,y2), not
draw_line(lineObject). But I am currently passing a text instance in
to draw_text. 
I realized this was a problem when I wanted to fix newline handling
across backends. The best way to do this is for the Text class to
split strings on newlines, do the layout in the front end, and then
call draw_text(x,y,s,font) for all the newline split strings in the
original string. Likewise, most of the text layout stuff like
alignment that is currently done in the backend should be moved to the
Text class. So I'll work on these changes in parallel.
JDH
From: Paul B. <ba...@st...> - 2004年03月12日 16:52:29
Hi John,
I have some proposed changes to the way matplotlib handles fonts. The suggested 
changes are along the lines of the W3C Cascading Style Sheet, Level 1 (CSS1; 
http://www.w3.org/TR/1999/REC-CSS1-19990111) document. Note that there is also 
a Level 2 and 2.1 document.
For fonts, HTML/XML documents can specify 5 font properties for font matching 
purposes. They are: font-family, font-style, font-variant, font-weight, and 
font-size. The font_family property is a list of prioritized font names. The 
nicer fonts are listed first, e.g. ['Lucida Grande', Verdana, Geneva, Lucida, 
Arial, Helvetica, sans-serif]. The first font name is apparently a very elegent 
sans-serif font that is common on Mac OS X. Verdana is common to Windows and 
Helvetica is common on UNIX/Linux. font-style can be normal, italic, or 
oblique; font-variant is normal or small-caps; font-weight has many options, 
e.g. normal, semi-bold, bold, etc.; and font-size also has many options, e.g. 
small, medium, large, smaller, larger, 10pt, 12pt, etc. The CSS1 document also 
gives a font matching algorithm in case your system doesn't have the exact font 
available.
The Text object in matplotlib has several similar attributes to the CSS1 font 
properties, so it would seem that you were aware of this approach. They are 
fontname, fontangle, fontweight, and fontsize. Given the similarities, my 
suggestion is to replace fontname with fontfamily and allow it to be a list of 
prioritized fonts. I also suggest replacing fontangle with fontstyle, adding 
fontvariant, and using the CSS1 options for these attributes.
The fontfamily approach makes it more likely that the more elegant fonts will be 
used by matplotlib and that if none of the recommended fonts are available, at 
least some font closely resembling the requested one will be used, i.e. some 
type of sans-serif font will be used if requested, instead of a serif font.
The CSS1 options for font weights are: [normal=400, bold=700, 100, 200, 300, 
400, 500, 600, 700, 800, 900, bolder, and lighter]. The latter two are relative 
values. It appears that newer fonts will use these numerical values to indicate 
their font weight, instead of using a descriptive names which are not uniform 
across font foundries.
Like the CSS1 options for font weight, the size options are: [xx-small, x-small, 
small, medium, large, x-large, xx-large, smaller, larger], plus point sizes. 
One of the benefits of using a name option for size is that the sizes are all 
relative to the medium size, which can be 10pt, 12pt, 14pt, etc. This would 
make it easy to change all the fonts in a plot just by changing the definition 
of the medium font from 12pt to 14pt.
As a final suggestion, we could have the Text object initialize the fontfamily 
attribute to a sans-serif font list, e.g. the one given above, since that seems 
to be a popular font family for many users.
Please let me know what you think about this suggestion and if you have any 
changes to the design.
 -- Paul
-- 
Paul Barrett, PhD Space Telescope Science Institute
Phone: 410-338-4475 ESS/Science Software Branch
FAX: 410-338-4767 Baltimore, MD 21218
From: John H. <jdh...@ac...> - 2004年03月10日 20:00:06
>>>>> "Perry" == Perry Greenfield <pe...@st...> writes:
 
 Perry> Todd and I just talked about this. There are two possible
 Perry> approaches, one of which should work and the other which we
 Perry> would have to think about. The simpler approach is to write
 Perry> a C extension using the Numeric API. As long as a small,
 Perry> rarely-used, subset of the Numeric API is not used (the
 Perry> UFunc API and some type conversion stuff in the type
 Perry> descriptor) 
OK, I'll start with plain vanilla Numeric along the lines Todd sent me
earlier, and we can do the (apparently straightforward)
numarray/numeric port when we have a prototype.
 Perry> I agree that this is the drawback. On the other hand,
 Perry> processor memory has grown much faster than image display
 Perry> memory. With a full screen image of 1024x1280 pixels, we
 Perry> are only talking about 5MB or so for a 32-bit deep
 Perry> display. Converting rgba all to floats means 20MB, while
 Perry> large is not overwhelming these days, and that is the worst
 Perry> case for interactive cases. I suppose it would be a bigger
 Perry> concern for non-interactive situations (e.g. PDF). But it
 Perry> would seem that in doing this simpler approach, we would
 Perry> have something that works sooner, and then we could think
 Perry> about how to handle cases where someone wants to generate a
 Perry> 4Kx4K PDF image (which is going to be one big PDF
 Perry> file!). I'd let's not let extreme cases like this drive the
 Perry> first implementation.
Agreed. If noone has any objections I think I'll start with rgba32 as
the common rendering format for the image module and we can special
case the smaller (grayscale UInt8 or UInt16) and larger (rgba floats)
cases after a prototype implementation.
I'm imagining an interface like
Frontend:
 im = image.fromarray(A) # NxM 
 im = image.fromarray(A, colormap) # NxM colormapped images
 im = image.fromarray(A) # NxMx3, no format needed
 im = image.fromarray(A) # NxMx4, no format needed
 im = image.fromfile('somefile.png')
 im.set_interpolate(image.BILINEAR)
 im.set_aspect_ratio(image.CONSTRAINED)
Backend:
 
 def draw_image(im):
 # Ascaled is width x height x 4 resampled using interpolation
 # and aspect constraints from above
 Ascaled = im.resize(viewport.width, viewport.height)
 renderer.draw_from_rgba(Ascaled, etc1, etc2)
 Perry> Well, I was just referring to the image file support that
 Perry> PIL supplies; the rest of PIL seems mostly redundant with
 Perry> matplotlib and array capabilities (if I remember right, I
 Perry> haven't really used PIL much). How much image file format
 Perry> support is built into agg?
Almost none, except for the raw (or almost raw) image types (ppm,
bmp). PNG, I have more or less figured out; borrowing the read/write
capabilities for other image format from PIL is a good idea.
JDH
From: Perry G. <pe...@st...> - 2004年03月10日 16:09:20
John Gill writes:
> Any other thoughts welcome...
>
> Not really related to images but...=20
>
> I've been thinking a bit about mapplotlib (no, that is not a typo).
>=20
> Quite often I find myself with numbers for different parts of the =
world=20
> that I want to map, shading regions different colours according to the =
> numbers.
>
> In fact, one of my early experiments with python and wxPython was to=20
> produce such a beast, but I'm not terribly happy with what I produced.
>
> matplotlib has lots of the goodies that mapplotlib would require: it =
has=20
> axes you can zoom and scroll, is great a drawing coloured polygons and =
can=20
> do legends.
>
> The problem I've tended to run into with mapping projects has been =
getting=20
> shape files that aren't distributed under a restrictive licence.
>=20
> Anyway, is there any interest out there in a mapplotlib?
>
> John=20
Well, sort of though on our part the interest is more in plotting
things on a map of the sky than the Earth (though occasionally, we
need to do that also). For us the biggest issue is handling all
the possible map coordinate projections. I would assume that is
also something you would have to worry about. We've given some
thought about how to do that sort of thing (as well as do thing
like polar plots). This would be a generalization of the matplotlib
transform mechanism. It isn't a real high priority for us yet.
The image stuff that John is talking about is much higher priority.
But if you have any thoughts of expanding on matplotlib for this
and are planning to use something other than simple rectangular
coordinates, I'd be interested in understanding how you will handle
map projections.
Perry
From: Perry G. <pe...@st...> - 2004年03月10日 15:59:25
> > > Andrew> 2) It's pretty clear that a lot of the TkAgg stuff was
> > > Andrew> taken directly out of PIL. 
> 
> This was news to me, but Perry confirmed it.
> 
By the way, I'd like to thank Andrew Straw for pointing this out.
I originally looked at how PIL handled blitting images to Tkinter
as a possible way of doing it for Chaco/Kiva, and it seemed to
work fine. But it didn't get used for Chaco/Kiva so it sat there
a while (and the license issue "to-do" faded from my memory)
until it I realized that it could be used for matplotlib/Tk/agg
when I gave it to Todd to use. By then I forgot to mention that
it was taken from PIL so I'm glad you noticed that.
Perry 
From: Perry G. <pe...@st...> - 2004年03月10日 15:57:20
>
> Hi Perry,
> You may not be aware that, although not officially supported, Lundh
> provided the following sample code (which I have used successfully to read
> bmp files and do fft's on them) for converting PIL to/from Numeric arrays
> via strings. It is quite fast. I think I probably found it in an email
> archive,
> Gary Ruben
>
Thanks for showing the code. I guess what I was referring to was
that native support by PIL would eliminate unnecessary memory copies
which occur when fromstring and tostring are used. But as I argue
in a previous message, I'm not currently worried that much about
that, but it seems that it would be nice if it weren't necessary
to go through that copying (from PIL image to string to array
rather than directly from PIL image to array)
[And I *meant* to check the spelling of Fredrik's name; I have a hard
time remembering the correct spelling :-) ]
Perry
From: Perry G. <pe...@st...> - 2004年03月10日 15:48:11
John Hunter writes:
> Sorry for the confusion. I meant that I was considering using
> antigrain to load/store/scale/convert/process the pixel buffers in an
> image module in the same way that PIL could be used, and that this has
> nothing per se to do with backend_agg. By "backends", I meant the
> same old backends we already have, backend_gd, backend_wx, backend_ps,
> etc..., each of which would implement a new method draw_image to
> render the image object to its respective canvases/displays. Whether
> this image object is PIL based or Agg based under the hood is an open
> question.
> 
> I hope I this clarifies rather than muddies the waters....
> 
OK, I understand what you meant.
> Perry> But initially, reading images into arrays seems like the
> Perry> most flexible and straightforward thing to do.
> 
> Agreed - I like the idea of making the user deal with endianess, etc,
> in loading the image data into arrays, and passing those to image
> module. Todd, is it reasonably straightforward to write extension
> code that is Numeric/numarray neutral for rank 2 and rank 3 arrays?
>
Todd and I just talked about this. There are two possible approaches,
one of which should work and the other which we would have to think
about. The simpler approach is to write a C extension using the
Numeric API. As long as a small, rarely-used, subset of the Numeric
API is not used (the UFunc API and some type conversion stuff
in the type descriptor) then numarray can use the same code with
only a change to the include file (which could be handled by an
#ifdef) Then the same C extension code could be use with either
Numeric or numarray. The catch is that it must be compiled to be
used with one or the other. I was thinking that the way around that
would be to do 2 things: have setup.py build for Numeric, numarray,
*or* both depending on what it found installed on the system. The
respective C extension modules would have different names (e.g.,
_image_Numeric.so/dll or _image_numarray.so/dll). There would also
be a wrapper module that uses numerix to determine which of these
C extensions to import. This is a bit clumsy (having to layer a 
module over it a la numerix, but it means only having one C source
file to handle both.
It might be possible for us to fiddle with numarray's structure 
definition so that the same compiled C code works with Numeric
and numarray arrays, but given that the API functions will generate
one or the other for creation, I'm not sure this is workable.
We will give it some thought.
My inclination is to use the first approach as a conservative but
workable solution.
> Perry> These arrays are passed to matplotlib rendering methods or
> Perry> functions and the dimensionality will tell the rendering
> Perry> engine how to interpret it. The question is how much the
> Perry> engine needs to know about the depth and representation of
> Perry> the display buffer and how much of these details are
> Perry> handled by agg (or other backends)
> 
> One thing that the rest of matplotlib tries to do is insulate as much
> complexity from the backends as possible. For example, the backends
> only know one coordinate system (display) and the various figure
> objects transform themselves before requesting, for example,
> draw_lines or draw_text. Likewise, the backends don't know about
> Line2D objects or Rectangle objects; the only know how to draw a line
> from x1, y1 to x2, y2, etc...
> 
> This suggests doing as much work as possible in the image module
> itself. For example, if the image module converted all image data to
> an RGBA array of floats, this would be totally general and the
> backends would only have to worry about one thing vis-a-vis images:
> dumping rgba floats to the canvas. Nothing about byte-order, RGB
> versus BGR, grayscale, colormaps and so on. Most or all of these
> things could be supported in the image module: the image module scales
> the image, handles the interpolation, and converts all pixel formats
> to an array of rgba floats. Then the backend takes over and renders.
> An array of RGBA UInt16s would probably suffice for just about
> everything, however.
> 
> The obvious potential downside here is performance and memory. You
> might be in a situation where the user passes in UInt8, the image
> module converts to floats, and the backend converts back to UInt8 to
> pass to display. Those of you who deal with image data a lot: to what
> extent is this a big concern? My first reaction is that on a
> reasonably modern PC, even largish images could be handled with
> reasonable speed.
> 
I agree that this is the drawback. On the other hand, processor 
memory has grown much faster than image display memory. With
a full screen image of 1024x1280 pixels, we are only talking about
5MB or so for a 32-bit deep display. Converting rgba all to floats
means 20MB, while large is not overwhelming these days, and that is
the worst case for interactive cases. I suppose it would be a bigger
concern for non-interactive situations (e.g. PDF). But it would seem
that in doing this simpler approach, we would have something that
works sooner, and then we could think about how to handle cases where
someone wants to generate a 4Kx4K PDF image (which is going to be
one big PDF file!). I'd let's not let extreme cases like this 
drive the first implementation.
> On the subject of PIL versus agg for the workhorse under the image
> module hood: I agree with the positive points things about PIL that
> you and Andrew brought up (stability, portability, wide user base,
> relevant functionality already implemented). In favor of agg I would
> add
> 
Well, I was just referring to the image file support that PIL supplies;
the rest of PIL seems mostly redundant with matplotlib and array
capabilities (if I remember right, I haven't really used PIL much).
How much image file format support is built into agg?
Perry 
From: gary r. <gr...@bi...> - 2004年03月10日 06:55:05
Hi Perry,
You may not be aware that, although not officially supported, Lundh
provided the following sample code (which I have used successfully to read
bmp files and do fft's on them) for converting PIL to/from Numeric arrays
via strings. It is quite fast. I think I probably found it in an email
archive,
Gary Ruben
-PilConvert.py-
#
# convert between numarrayal arrays and PIL image memories
#
# fredrik lundh, october 1998
#
# fr...@py...
# http://www.pythonware.com
#
import numarray
import Image
def image2array(im):
 if im.mode not in ("L", "F"):
 raise ValueError, "can only convert single-layer images"
 if im.mode == "L":
 a = numarray.fromstring(im.tostring(), numarray.UInt8)
 else:
 a = numarray.fromstring(im.tostring(), numarray.Float32)
 a.shape = im.size[1], im.size[0]
 return a
def array2image(a):
 if a.typecode() == numarray.UInt8:
 mode = "L"
 elif a.typecode() == numarray.Float32:
 mode = "F"
 else:
 raise ValueError, "unsupported image mode"
 return Image.fromstring(mode, (a.shape[1], a.shape[0]), a.tostring())
-ffts.py-
import PilConvert
import Image
from numarray import *
from numarray.fft import *
def doFft(im):
 nim = PilConvert.image2array(im)
 im_fft = abs(real_fft2d(nim))
 im_fft = log(im_fft + 1) # convert levels for display
 scale = 255. / max(im_fft.flat)
 im_fft = (im_fft * scale).astype(UInt8)
 imo = PilConvert.array2image(im_fft)
 return imo
im = Image.open('rm.bmp')
imo = doFft(im)
imo.save('rm_fourier.bmp', 'BMP')
*********** REPLY SEPARATOR ***********
On 9/03/2004 at 17:58 Perry Greenfield wrote:
> John Hunter writes:
> 
> > I'm starting to think about adding image support and wanted to get
> > some input about what it should include and how it should be designed.
> > The ideas are still pretty nascent but here is where I was planning to
> > start.
> > 
> > Create an image extension built around agg (not backend_agg). This
> > would be a free standing extension not tied to any of the backends
> > with the responsibility of loading image data from a variety of
> > sources into a pixel buffer, and resizing it to a desired pixel size
> > (dependent on the axes window) with customizable interpolation.
> > 
> I guess I'm confused by terminology. What do you intend "backend"
> to mean for images. A common interface for reading different
> image formats? Speaking of which...
> 
> > Inputs: what file formats should be supported? 
> > 
> > * I can do PNG rather easily since I already had to interface agg
> > with png for save capabilities in backend_agg.
> > 
> I guess I would argue for what you refer to below, that the
> functionality to read image formats should be decoupled, at least
> initially, from the plotting (display?) package. In fact, initially
> it may make sense just to use PIL for that functionality alone until
> we understand better what really needs to be integrated into the 
> display package. (The main drawback of PIL is that it doesn't support
> either Numeric or numarray, and Lundt isn't inclined to support
> either unless either is part of the Python Standard Library. It
> may turn out that we could add it to PIL, or extract from PIL
> the image file support component for our purposes. I suspect that
> that stuff is pretty stable). But initially, reading images into
> arrays seems like the most flexible and straightforward thing to
> do.
> 
> > * As for raw pixel data, should we try to support
> > grayscale/luminance, rgb and rgba with the platform dependent byte
> > ordering problems, or leave it to the user to load these into a
> > numeric/numarray and init the image with that? Should we follow
> > PILs lead here and just provide a fromstring method with format
> > strings?
> > 
> I haven't given this a great deal of thought, but again, arguing
> for simplicity, that the array representations should be simple.
> For example, nxm dim array implies luminance, nxmx3 implies
> rgb, nxmx4 implies rgba. The I/O module always fills the arrays
> in native byte order. I suppose that some thought should be given
> to the default array type. One possibility is to use Float32 with
> normalized values (1.0=max), but it is probably important to keep
> integer values from some image formats (like png). Floats give
> the greatest flexibility and independence from the display hardware,
> if sometimes wasteful of memory. The second type to support would be
> UInt8 (I admit I could be stupidly overlooking something).
> 
> These arrays are passed to matplotlib rendering methods
> or functions and the dimensionality will tell the rendering engine
> how to interpret it. The question is how much the engine needs to
> know about the depth and representation of the display buffer
> and how much of these details are handled by agg (or other backends)
> 
> 
> > * What raw types should be supported: 8 bit luminance, 16 bit
> > luminance, 8 bit rgb, 8bit rgba, 16 bit rgb or rgba?
> > 
> > Resizing: Generally the axes viewport and the image dimensions will
> > not agree. Several possible solutions - perhaps all need to be
> > supported:
> > 
> > * a custom axes creation func that fits the image when you just want
> > to view and draw onto single image (ie no multiple subplots).
> > 
> > * resize to fit, resize constrained aspect ratio, plot in current
> > axes and clip image outside axes viewlim
> > 
> > * with resizing, what pixel interpolation schemes are critical? agg
> > supports several: nearest neighbor, blinear, bicubic, spline,
> > sinc.
> >
> Here again I would argue that the resizing functions could be separated 
> into a separate module until we understand better how they should
> be integrated into the interface. So for now, require a user to
> apply a resampling function to an image. Something like this might
> be a good initial means of handling images.
> 
> im = readpng("mypicture.png") # returns a rgb array (nxmx3) unless alpha
> # is part of png files (I'm that ignorant).
> rebinned_im = bilinear(im, axisinfo...)
> 
> Then use rebinned_im for a pixel-to-pixel display in the plot canvas
> (with appropriate offset and clipping). This isn't quite as convenient
> as one step from file to display, but it should get us some flexible 
> functionality faster and doesn't restrict more integrated means of
> displaying images. There are other approaches to decoupling that are
> probably more object oriented.
> 
> I'll think more about this (and you can clarify more what you mean
> as well if I'm confused about what you are saying).
> 
> Perry 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> Matplotlib-devel mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
------------------------------------
Gary Ruben gr...@bi...
<http://users.bigpond.net.au/gazzar>
From: John H. <jdh...@ac...> - 2004年03月10日 04:32:11
>>>>> "Perry" == Perry Greenfield <pe...@st...> writes:
 >> Create an image extension built around agg (not backend_agg).
 >> This would be a free standing extension not tied to any of the
 >> backends with the responsibility of loading image data from a
 >> variety of sources into a pixel buffer, and resizing it to a
 >> desired pixel size (dependent on the axes window) with
 >> customizable interpolation.
 Perry> I guess I'm confused by terminology. What do you intend
 Perry> "backend" to mean for images. A common interface for
 Perry> reading different image formats? Speaking of which...
Sorry for the confusion. I meant that I was considering using
antigrain to load/store/scale/convert/process the pixel buffers in an
image module in the same way that PIL could be used, and that this has
nothing per se to do with backend_agg. By "backends", I meant the
same old backends we already have, backend_gd, backend_wx, backend_ps,
etc..., each of which would implement a new method draw_image to
render the image object to its respective canvases/displays. Whether
this image object is PIL based or Agg based under the hood is an open
question.
I hope I this clarifies rather than muddies the waters....
 Perry> But initially, reading images into arrays seems like the
 Perry> most flexible and straightforward thing to do.
Agreed - I like the idea of making the user deal with endianess, etc,
in loading the image data into arrays, and passing those to image
module. Todd, is it reasonably straightforward to write extension
code that is Numeric/numarray neutral for rank 2 and rank 3 arrays?
 Perry> These arrays are passed to matplotlib rendering methods or
 Perry> functions and the dimensionality will tell the rendering
 Perry> engine how to interpret it. The question is how much the
 Perry> engine needs to know about the depth and representation of
 Perry> the display buffer and how much of these details are
 Perry> handled by agg (or other backends)
One thing that the rest of matplotlib tries to do is insulate as much
complexity from the backends as possible. For example, the backends
only know one coordinate system (display) and the various figure
objects transform themselves before requesting, for example,
draw_lines or draw_text. Likewise, the backends don't know about
Line2D objects or Rectangle objects; the only know how to draw a line
from x1, y1 to x2, y2, etc...
This suggests doing as much work as possible in the image module
itself. For example, if the image module converted all image data to
an RGBA array of floats, this would be totally general and the
backends would only have to worry about one thing vis-a-vis images:
dumping rgba floats to the canvas. Nothing about byte-order, RGB
versus BGR, grayscale, colormaps and so on. Most or all of these
things could be supported in the image module: the image module scales
the image, handles the interpolation, and converts all pixel formats
to an array of rgba floats. Then the backend takes over and renders.
An array of RGBA UInt16s would probably suffice for just about
everything, however.
The obvious potential downside here is performance and memory. You
might be in a situation where the user passes in UInt8, the image
module converts to floats, and the backend converts back to UInt8 to
pass to display. Those of you who deal with image data a lot: to what
extent is this a big concern? My first reaction is that on a
reasonably modern PC, even largish images could be handled with
reasonable speed.
On the subject of PIL versus agg for the workhorse under the image
module hood: I agree with the positive points things about PIL that
you and Andrew brought up (stability, portability, wide user base,
relevant functionality already implemented). In favor of agg I would
add
 * we're already distributing agg so negligible code bloat; PIL is
 largish and not the easiest install. Distributing fonttools has
 been a mess that I don't want to repeat.
 * impressive suite of pixel conversion funcs, interpolators, filters
 and transforms built in
 * easy and efficient integration with backend_agg, which the GUIs
 are converging around. 
 * numeric/numarray support from the ground up
Downsides
 * less portable - requires modern c++ compiler
 * more up front work (but most is already done in C++ and just needs
 exposing)
JDH
From: Andrew S. <str...@as...> - 2004年03月10日 00:33:30
<snipped lots of interesting discussion...>
> I guess I would argue for what you refer to below, that the
> functionality to read image formats should be decoupled, at least
> initially, from the plotting (display?) package. In fact, initially
> it may make sense just to use PIL for that functionality alone until
> we understand better what really needs to be integrated into the
> display package. (The main drawback of PIL is that it doesn't support
> either Numeric or numarray, and Lundt isn't inclined to support
> either unless either is part of the Python Standard Library. It
> may turn out that we could add it to PIL, or extract from PIL
> the image file support component for our purposes. I suspect that
> that stuff is pretty stable). But initially, reading images into
> arrays seems like the most flexible and straightforward thing to
> do.
Disclaimer: I surely don't understand all of the requirements for 
matplotlib imaging.
I would also suggest PIL, sticking as much as possible to the 
pure-Python interface. I suggest this because some OSs (well, Mac OS X 
is what I'm thinking of) are supposed to have native image-handling 
routines which are fine-tuned to their hardware and unlikely to be beat 
by some multi-platform project. (For example, I've heard that Apple's 
PNG handling is faster and better than libpng.) If someone modified PIL 
to take advantage of these platform-specific features, we would reap 
the benefits. Then again, this argument assumes someone will someday 
do that.
>> * As for raw pixel data, should we try to support
>> grayscale/luminance, rgb and rgba with the platform dependent byte
>> ordering problems, or leave it to the user to load these into a
>> numeric/numarray and init the image with that? Should we follow
>> PILs lead here and just provide a fromstring method with format
>> strings?
>>
> I haven't given this a great deal of thought, but again, arguing
> for simplicity, that the array representations should be simple.
> For example, nxm dim array implies luminance, nxmx3 implies
> rgb, nxmx4 implies rgba. The I/O module always fills the arrays
> in native byte order. I suppose that some thought should be given
> to the default array type. One possibility is to use Float32 with
> normalized values (1.0=max), but it is probably important to keep
> integer values from some image formats (like png). Floats give
> the greatest flexibility and independence from the display hardware,
> if sometimes wasteful of memory. The second type to support would be
> UInt8 (I admit I could be stupidly overlooking something).
I think the format string idea is a good one. An nxm dim array could 
be luminance, alpha, or possibly colormapped -- it's not necessarily 
known in advance what data type it is, although a guess would probably 
be right 99% of the time.
I also vote use a floating-point representation whenever possible. 
It's clear that 8 bits per color aren't enough for many purposes.
<snipped more interesting discussion...>
From: Perry G. <pe...@st...> - 2004年03月09日 23:15:38
John Hunter writes:
> I'm starting to think about adding image support and wanted to get
> some input about what it should include and how it should be designed.
> The ideas are still pretty nascent but here is where I was planning to
> start.
> 
> Create an image extension built around agg (not backend_agg). This
> would be a free standing extension not tied to any of the backends
> with the responsibility of loading image data from a variety of
> sources into a pixel buffer, and resizing it to a desired pixel size
> (dependent on the axes window) with customizable interpolation.
> 
I guess I'm confused by terminology. What do you intend "backend"
to mean for images. A common interface for reading different
image formats? Speaking of which...
> Inputs: what file formats should be supported? 
> 
> * I can do PNG rather easily since I already had to interface agg
> with png for save capabilities in backend_agg.
> 
I guess I would argue for what you refer to below, that the
functionality to read image formats should be decoupled, at least
initially, from the plotting (display?) package. In fact, initially
it may make sense just to use PIL for that functionality alone until
we understand better what really needs to be integrated into the 
display package. (The main drawback of PIL is that it doesn't support
either Numeric or numarray, and Lundt isn't inclined to support
either unless either is part of the Python Standard Library. It
may turn out that we could add it to PIL, or extract from PIL
the image file support component for our purposes. I suspect that
that stuff is pretty stable). But initially, reading images into
arrays seems like the most flexible and straightforward thing to
do.
> * As for raw pixel data, should we try to support
> grayscale/luminance, rgb and rgba with the platform dependent byte
> ordering problems, or leave it to the user to load these into a
> numeric/numarray and init the image with that? Should we follow
> PILs lead here and just provide a fromstring method with format
> strings?
> 
I haven't given this a great deal of thought, but again, arguing
for simplicity, that the array representations should be simple.
For example, nxm dim array implies luminance, nxmx3 implies
rgb, nxmx4 implies rgba. The I/O module always fills the arrays
in native byte order. I suppose that some thought should be given
to the default array type. One possibility is to use Float32 with
normalized values (1.0=max), but it is probably important to keep
integer values from some image formats (like png). Floats give
the greatest flexibility and independence from the display hardware,
if sometimes wasteful of memory. The second type to support would be
UInt8 (I admit I could be stupidly overlooking something).
These arrays are passed to matplotlib rendering methods
or functions and the dimensionality will tell the rendering engine
how to interpret it. The question is how much the engine needs to
know about the depth and representation of the display buffer
and how much of these details are handled by agg (or other backends)
> * What raw types should be supported: 8 bit luminance, 16 bit
> luminance, 8 bit rgb, 8bit rgba, 16 bit rgb or rgba?
> 
> Resizing: Generally the axes viewport and the image dimensions will
> not agree. Several possible solutions - perhaps all need to be
> supported:
> 
> * a custom axes creation func that fits the image when you just want
> to view and draw onto single image (ie no multiple subplots).
> 
> * resize to fit, resize constrained aspect ratio, plot in current
> axes and clip image outside axes viewlim
> 
> * with resizing, what pixel interpolation schemes are critical? agg
> supports several: nearest neighbor, blinear, bicubic, spline,
> sinc.
>
Here again I would argue that the resizing functions could be separated 
into a separate module until we understand better how they should
be integrated into the interface. So for now, require a user to
apply a resampling function to an image. Something like this might
be a good initial means of handling images.
im = readpng("mypicture.png") # returns a rgb array (nxmx3) unless alpha
 # is part of png files (I'm that ignorant).
rebinned_im = bilinear(im, axisinfo...)
Then use rebinned_im for a pixel-to-pixel display in the plot canvas
(with appropriate offset and clipping). This isn't quite as convenient
as one step from file to display, but it should get us some flexible 
functionality faster and doesn't restrict more integrated means of
displaying images. There are other approaches to decoupling that are
probably more object oriented.
I'll think more about this (and you can clarify more what you mean
as well if I'm confused about what you are saying).
Perry 
From: John H. <jdh...@ac...> - 2004年03月09日 17:54:44
>>>>> "John" == John N S Gill <jn...@eu...> writes:
 John> Quite often I find myself with numbers for different parts
 John> of the world that I want to map, shading regions different
 John> colours according to the numbers.
 John> The problem I've tended to run into with mapping projects
 John> has been getting shape files that aren't distributed under a
 John> restrictive licence.
I've experimented with this a bit using shapefiles from the national
atlas (I think they are distributed under a permissive license).
thuban has a nice python interface for reading shape files and their
associated db files. I've held off on pursuing this functionality
until we get an efficient path/polygon extension, which has been
discussed a number of times but is still on the TODO list. 
The example below renders the US map from 2000 polygons, and is slow
for interactive use with that many polygons.
 http://nitace.bsd.uchicago.edu:8080/files/share/map.png
For nice map navigation, you would probably want a better navigation
toolbar (hand pan, zoom to region) which was discussed many moons ago
but has also languished due to lack of time -
http://sourceforge.net/mailarchive/message.php?msg_id=6542965
Here's some example code:
# shapefile from
# http://edcftp.cr.usgs.gov/pub/data/nationalatlas/statesp020.tar.gz
# shapefile lib from http://thuban.intevation.org
import shapelib, dbflib, shptree
from matplotlib.patches import Polygon
from matplotlib.matlab import *
filename = 'statesp020.shp'
dbfile = 'statesp020.dbf'
shp = shapelib.ShapeFile(filename)
numShapes, type, smin, smax = shp.info()
ax = gca()
dpi = ax.dpi
bbox = ax.bbox
transx = ax.xaxis.transData
transy = ax.yaxis.transData
left=[]; right=[]; bottom=[]; top=[]
db = dbflib.open(dbfile)
# just get the main polys for each state
seen = {}
for i in range(numShapes):
 rec = db.read_record(i)
 state = rec['STATE']
 area = rec['AREA']
 obj = shp.read_object(i)
 verts = obj.vertices()[0]
 if seen.has_key(state):
 have, tmp = seen[state]
 if area>have:
 seen[state] = area, verts
 else:
 seen[state] = area, verts 
 
for state, tup in seen.items(): 
 area, verts = tup
 poly = Polygon(dpi, bbox, verts,
 fill=False,
 transx=transx, transy=transy)
 x = [tx for tx, ty in verts]
 y = [ty for tx, ty in verts]
 ax.xaxis.datalim.update(x)
 ax.yaxis.datalim.update(y)
 ax.add_patch(poly)
set(gca(), 'xlim', ax.xaxis.datalim.bounds())
set(gca(), 'ylim', ax.yaxis.datalim.bounds())
savefig('map', dpi=150)
axis('Off')
show() 
From: John N S G. <jn...@eu...> - 2004年03月09日 16:40:15
 
> Any other thoughts welcome...
 
Not really related to images but... 
I've been thinking a bit about mapplotlib (no, that is not a typo).
Quite often I find myself with numbers for different parts of the world
that I want to map, shading regions different colours according to the
numbers.
In fact, one of my early experiments with python and wxPython was to
produce such a beast, but I'm not terribly happy with what I produced.
matplotlib has lots of the goodies that mapplotlib would require: it
has axes you can zoom and scroll, is great a drawing coloured polygons
and can do legends.
The problem I've tended to run into with mapping projects has been
getting shape files that aren't distributed under a restrictive licence.
Anyway, is there any interest out there in a mapplotlib?
John
From: John H. <jdh...@ac...> - 2004年03月09日 16:10:57
I'm starting to think about adding image support and wanted to get
some input about what it should include and how it should be designed.
The ideas are still pretty nascent but here is where I was planning to
start.
Create an image extension built around agg (not backend_agg). This
would be a free standing extension not tied to any of the backends
with the responsibility of loading image data from a variety of
sources into a pixel buffer, and resizing it to a desired pixel size
(dependent on the axes window) with customizable interpolation.
Inputs: what file formats should be supported? 
 * I can do PNG rather easily since I already had to interface agg
 with png for save capabilities in backend_agg.
 * As for raw pixel data, should we try to support
 grayscale/luminance, rgb and rgba with the platform dependent byte
 ordering problems, or leave it to the user to load these into a
 numeric/numarray and init the image with that? Should we follow
 PILs lead here and just provide a fromstring method with format
 strings?
 * What raw types should be supported: 8 bit luminance, 16 bit
 luminance, 8 bit rgb, 8bit rgba, 16 bit rgb or rgba?
Resizing: Generally the axes viewport and the image dimensions will
not agree. Several possible solutions - perhaps all need to be
supported:
 
 * a custom axes creation func that fits the image when you just want
 to view and draw onto single image (ie no multiple subplots).
 * resize to fit, resize constrained aspect ratio, plot in current
 axes and clip image outside axes viewlim
 * with resizing, what pixel interpolation schemes are critical? agg
 supports several: nearest neighbor, blinear, bicubic, spline,
 sinc.
Backends:
 I am thinking about using the same approach as in ft2font. Have the
 image backend provide the load/resize/interpolate methods and fill a
 pixel buffer of appropriate size and letting the backends do
 whatever they want with it. Agg can blend the image with the
 drawing buffer, gtk can draw from an rgba buffer. Not sure about PS
 yet. paint and wx can use their respective APIs to copy the pixel
 buffer.
Any other thoughts welcome...
JDH
From: John N S G. <jn...@eu...> - 2004年03月09日 13:18:20
Attachments: table.py
John,
Attached is a new version of table.py where I have added some methods to
allow auto-scaling of the fonts used in the tables. 
The code simply shrinks the fontsize until it finds a value that fits.
John
From: John H. <jdh...@ac...> - 2004年03月08日 23:52:48
>>>>> "Todd" == Todd Miller <jm...@st...> writes:
 Todd> JDH... do you have any idea where to put it?
I created a dir in CVS "license" which contains
 LICENSE - the matplotlib license
 LICENSE_PAINT - not really required anymore since font.cpp is no
 longer used
 LICENSE_PIL - you can refer to this in the appropriate tkagg src
 files
I also made a committed of couple of minor changes earlier to the
tkagg src that Andrew suggested to me that enable it to build cleanly
on OS X. With the current CVS setup.py and setupext.py, I can build
all the backends on linux, win32 and darwin, which is *a good thing*
:-).
JDH
From: Todd M. <jm...@st...> - 2004年03月08日 23:31:28
On Mon, 2004年03月08日 at 17:41, Andrew Straw wrote:
> Hi matplotlib developers,
> 
> John has rightly directed me to the developers list with the following 
> email. So now, after subscribing, I have a couple of suggestions for 
> the developer of the TkAgg backend. (John Miller?)
I'm *Todd* Miller. My SF login is jaytmiller.
> 
> Begin forwarded message:
> 
> > From: John Hunter <jdh...@ac...>
> > Date: Tue Mar 9, 2004 2:52:33 AM Australia/Adelaide
> > To: Andrew Straw <str...@as...>
> > Subject: Re: TkAgg backend issues
> >
> >>>>>> "Andrew" == Andrew Straw <str...@as...> writes:
> >
> > Andrew> Hi John, A couple more quick notes:
> >
> > Andrew> 1) It might be very useful to put the following comment in
> > Andrew> setupext.py in the add_tk_flags section so that idiots
> > Andrew> like me don't build the TkAgg backend against tk8.4, even
> > Andrew> though their Tkinter uses 8.3!
> >
> > Andrew> # Make sure you use the Tk version given by
> > Andrew> Tkinter.TkVersion # or else you'll build for a wrong
> > Andrew> version of the Tcl # interpreter (leading to nasty
> > Andrew> segfaults).
OK. I added this to setupext.py. Thanks for the suggestion.
> >
> > Andrew> 2) It's pretty clear that a lot of the TkAgg stuff was
> > Andrew> taken directly out of PIL. 
This was news to me, but Perry confirmed it.
> Therefore, we need to live up
> > Andrew> to their (not very challenging) license conditions: we
> > Andrew> have to include their copyright notice and their
> > Andrew> permissions as specified in Imaging-1.1.x/README.
> >
Here's what I think we have to include:
--------------------------------------------------------------------
Software License
--------------------------------------------------------------------
The Python Imaging Library is
Copyright (c) 1997-2002 by Secret Labs AB
Copyright (c) 1995-2002 by Fredrik Lundh
By obtaining, using, and/or copying this software and/or its
associated documentation, you agree that you have read, understood,
and will comply with the following terms and conditions:
Permission to use, copy, modify, and distribute this software and its
associated documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appears in all
copies, and that both that copyright notice and this permission notice
appear in supporting documentation, and that the name of Secret Labs
AB or the author not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR
ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
JDH... do you have any idea where to put it?
Thanks for the feedback,
Todd Miller
-- 
Todd Miller <jm...@st...>

Showing results of 51

<< < 1 2 3 > >> (Page 2 of 3)
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 によって変換されたページ (->オリジナル) /