[matplotlib-devel] A question about cbook.is_string_like
Hello everybody, I'm in the process of replacing R by matplotlib to plot all of our charts. I'm hacking the PDF backend because I need this format to import charts in ConTeXt (this is TeX macro package, similar to LaTeX, we use to produce PDF reports). My first question, very basic, is why function is_string_like, in module cbook, doesn't simply return isinstance(s, types.StringTypes) instead of try: obj + '' except (TypeError, ValueError): return 0 return 1 Thanks for your work, Nicolas -- Garden - Marketing & Datamining Consultancy Nicolas Grilly Tel +33 1 45 72 48 78 Mob +33 6 03 00 25 34 www.garden-paris.com - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] A question about cbook.is_string_like
On Sun, Nov 05, 2006 at 06:07:50PM +0100, Nicolas Grilly wrote: > I'm hacking the PDF backend because I need this format to import > charts in ConTeXt (this is TeX macro package, similar to LaTeX, we use > to produce PDF reports). I am all for a good PDF backend, but you should be aware that under unices you can tell matplotlib to use a distiller, as illustrated in: http://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg00160.html Gaël - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] A question about cbook.is_string_like
Gael Varoquaux wrote: > On Sun, Nov 05, 2006 at 06:07:50PM +0100, Nicolas Grilly wrote: > >> I'm hacking the PDF backend because I need this format to import >> charts in ConTeXt (this is TeX macro package, similar to LaTeX, we use >> to produce PDF reports). >> > > I am all for a good PDF backend, but you should be aware that under > unices you can tell matplotlib to use a distiller, as illustrated in: > http://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg00160.html > BTW, what's the "official" status of the PDF backend? Last I checked (a month or so ago), it seemed to work fine, has a couple of Python 2.4-isms, but was generally great. I was surprised that it didn't appear to make it onto the list of officially-sanctioned backends (e.g. in the "save" button on the toolbar, IIRC). I found it really useful for making vectorized figures with alpha for inclusion in a pdflatex document. (Is that possible going via an (e)ps route?) When I get back to that manuscript (ahem), I'll probably try to bang the PDF backend further into shape. What bits need to be added/fixed? Is the PDF backend TODO list documented anywhere? where? -Andrew - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] A question about cbook.is_string_like
On Sun, Nov 05, 2006 at 09:27:54AM -0800, Andrew Straw wrote: > When I get back to that manuscript (ahem), I'll probably try to bang > the PDF backend further into shape. That would be great for pdf generation under windows, where you can hardly assume the user has xpdf or epstopdf installed. It has been holding back the portability of pyreport (which is by default non portable as I don't have windows). Gaël - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] A question about cbook.is_string_like
Hi Gaël, Gael Varoquaux <[EMAIL PROTECTED]> wrote: > I am all for a good PDF backend, but you should be aware that under > unices you can tell matplotlib to use a distiller, as illustrated in: > http://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg00160.html Yes, I know it's possible to use a distiller under Unices to convert my PDF into an EPS, but I'm under Windows... Moreover, I think it's good to have a more straightforward way to produce PDF charts, without requiring a distiller. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] A question about cbook.is_string_like
Hi Andrew, Andrew Straw <[EMAIL PROTECTED]> wrote: > I'm not speaking with the authority of one who actually wrote the > function or uses it, so I don't know the specific reasons, if there are > any. However, this kind of thing is common (and encouraged) practice in > Python. It's a use of "duck typing". For more info see > http://en.wikipedia.org/wiki/Duck_typing Thank you for your answer. I use Python for two years now and know "duck typing" very well. It's one of the most powerful features of this language. But in this function, I don't like the idea to try an operation on a string, and wait for an exception in order to know if we really have a string or not. It's not very efficient, nor very beautiful. I guess initial developer did that to keep compatibility with old Python versions. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] A question about cbook.is_string_like
On 11/5/06, Andrew Straw <[EMAIL PROTECTED]> wrote: > BTW, what's the "official" status of the PDF backend? Last I checked (a > month or so ago), it seemed to work fine, has a couple of Python > 2.4-isms, but was generally great. I was surprised that it didn't appear > to make it onto the list of officially-sanctioned backends (e.g. in the > "save" button on the toolbar, IIRC). I found it really useful for making > vectorized figures with alpha for inclusion in a pdflatex document. (Is > that possible going via an (e)ps route?) When I get back to that > manuscript (ahem), I'll probably try to bang the PDF backend further > into shape. What bits need to be added/fixed? Is the PDF backend TODO > list documented anywhere? where? I agree: the PDF backend is almost usable! I've just some issues with: - text alignment (I fixed it on my working copy of matplotlib); - accentuated characters (nearly fixed); - embedding of TTF fonts in the PDF (in progress - we need to limit the /Widths array to the 256 characters used in WinAnsiEncoding). - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] A question about cbook.is_string_like
> "Andrew" == Andrew Straw <[EMAIL PROTECTED]> writes: Andrew> BTW, what's the "official" status of the PDF backend? Last Andrew> I checked (a month or so ago), it seemed to work fine, has Andrew> a couple of Python 2.4-isms, but was generally great. I Andrew> was surprised that it didn't appear to make it onto the Andrew> list of officially-sanctioned backends (e.g. in the "save" Andrew> button on the toolbar, IIRC). I found it really useful for Hmm, in backend_agg.py FigureCanvasAgg.print_figure there is an entry for pdf in the print switch routine. Which backend are you having trouble on? All the *Agg backends should just pass the print request right through to agg, which should handle PDF (and PS, EPS, SVG, etc...) JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] A question about cbook.is_string_like
> "Nicolas" == Nicolas Grilly <[EMAIL PROTECTED]> writes: Nicolas> But in this function, I don't like the idea to try an Nicolas> operation on a string, and wait for an exception in order Nicolas> to know if we really have a string or not. It's not very Nicolas> efficient, nor very beautiful. Nicolas> I guess initial developer did that to keep compatibility Nicolas> with old Python versions. I did it because it is general, elegant, and efficiency doesn't matter here (any string operation is insignificant to the work we do making a figure). What if a user writes their own string class, eg someone wants a mutable string, or a lower case string, or any number of custom string objects, and these aren't covered by the types module? We make heavy use of duck typing in matplotlib, and it hasn't caused us any problems I know of. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] Question about ft2font.get_charmap
In module ft2font, the method FT2Font.get_charmap returns a dict that maps glyph indices to char codes. I don't understand the purpose of this mapping, and why the method doesn't return the reverse mapping, i.e. char codes mapped to glyph indices. For example, in backend_ps.py, line 754, the charmap is immediately reversed, just after being loaded: cmap = font.get_charmap() glyphd = reverse_dict(cmap) Thanks, Nicolas Grilly - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] PDF backend (was: A question about cbook.is_string_like)
Andrew Straw <[EMAIL PROTECTED]> writes: > When I get back to that manuscript (ahem), I'll probably try to bang > the PDF backend further into shape. What bits need to be > added/fixed? Is the PDF backend TODO list documented anywhere? > where? The TODO list is in the comments of backend_pdf.py: # * the alpha channel of images # * image compression could be improved (PDF supports png-like compression) # * encoding of fonts, including mathtext fonts and unicode support # * Type 1 and Base-14 font support (i.e., "pdf.use_afm") # * TTF support has lots of small TODOs, e.g. how do you know if a font # is serif/sans-serif, or symbolic/non-symbolic? # * draw_markers, draw_line_collection, etc. # * use_tex I think the most important thing to fix is the font support. TTF embedding mostly works but I haven't figured out the encoding issues, and it would be really nice to be able to do font subsetting. I was going to look into the Fonttools library by Just van Rossum, but lately I've been too busy with other things to. "Nicolas Grilly" <[EMAIL PROTECTED]> writes: > I've just some issues with: > - text alignment (I fixed it on my working copy of matplotlib); Great! Is there a patch somewhere? -- Jouni - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] PDF backend
> "Jouni" == Jouni K Seppanen <[EMAIL PROTECTED]> writes: Jouni> able to do font subsetting. I was going to look into the Jouni> Fonttools library by Just van Rossum, but lately I've been Jouni> too busy with other things to. FYI, matplotlib used to depend on fonttools, but we found the dependency too onerous and booted it and wrote our own, lighter freetype support. So I would be reluctant to reintroduce this dependency. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] A question about cbook.is_string_like
"Nicolas Grilly" <[EMAIL PROTECTED]> writes: [about is_string_like] > But in this function, I don't like the idea to try an operation on a > string, and wait for an exception in order to know if we really have a > string or not. It's not very efficient, nor very beautiful. I wouldn't worry about efficiency until there is a demonstrable need to speed something up. > I guess initial developer did that to keep compatibility with old > Python versions. I've always thought that is_string_like is there to allow compatibility with _future_ code where someone is using a new kind of string-like object that works just like a string but for which isinstance(x, (str, unicode)) is false. -- Jouni - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] PDF backend
John Hunter <[EMAIL PROTECTED]> writes: > FYI, matplotlib used to depend on fonttools, but we found the > dependency too onerous and booted it and wrote our own, lighter > freetype support. So I would be reluctant to reintroduce this > dependency. OK. Was it just that you don't want to require mpl users to install fonttools, or were there other problems with it? Does anyone here have experience with subsetting TrueType fonts (or Type 1 or OpenType, for that matter)? One pretty frequent complaint is that the eps files produced by matplotlib can be huge because they include the full font. Nowadays some popular fonts include characters for Greek, Cyrillic, Hebrew, Arabic, and possibly even Chinese, Japanese, and Korean, so a font can be several megabytes large. -- Jouni - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] PDF backend
> "Jouni" == Jouni K Seppanen <[EMAIL PROTECTED]> writes: Jouni> OK. Was it just that you don't want to require mpl users to Jouni> install fonttools, or were there other problems with it? One problem was that it was large compared to mpl at the time, and mpl was pure python. So it complicated the distribution to have a large piece of extension code that wasn't quite as ubiquitous as numpy. Of course now mpl is much larger and has it's own extension code headaches. Jouni> Does anyone here have experience with subsetting TrueType Jouni> fonts (or Type 1 or OpenType, for that matter)? One pretty Jouni> frequent complaint is that the eps files produced by Jouni> matplotlib can be huge because they include the full Jouni> font. Nowadays some popular fonts include characters for Jouni> Greek, Cyrillic, Hebrew, Arabic, and possibly even Chinese, Jouni> Japanese, and Korean, so a font can be several megabytes Jouni> large. I would love for someone how to figure out how to extract and embed just the needed glyphs rather than dump the whole file in. I'm 99% sure this is possible, it just takes some dedication. JDH - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Question about ft2font.get_charmap
On 11/5/06, Nicolas Grilly <[EMAIL PROTECTED]> wrote: > In module ft2font, the method FT2Font.get_charmap returns a dict that > maps glyph indices to char codes. > > I don't understand the purpose of this mapping, and why the method > doesn't return the reverse mapping, i.e. char codes mapped to glyph > indices. The ft2font module provides a Python interface to the FT2Font C API. get_charmap is one of the methods in this API as is set_charmap. A font can have multiple character maps. get_charmap() returns the default one. Others can be specified by providing an argument to get_charmap(). To add a new charmap to the font, you must first find out what charmaps it contains, so get_charmap is needed for this. In addition, changing this method to return the reverse mapping would violate the rule of least surprise. Note that creating the reverse dict is easy in Python. -- Paul > For example, in backend_ps.py, line 754, the charmap is immediately > reversed, just after being loaded: > > cmap = font.get_charmap() > glyphd = reverse_dict(cmap) > > Thanks, > > Nicolas Grilly > - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel