Class LineSelector

Hello,

first of all let me say: Matplotlib is really great. I'm used looking at
xplt-graphics and MPL is just beautifull!

For my programs I needed the coordinates of mouseclick and -release point so
I modified the HorizontalSpanSelector. With the class in the attached file
it is possible to use functions needing those coordinates.

In the example a large number of pionts is added to the plot so that you can
check out performance improvments when using blitting. This however is only
possible when calling
python LinseSelector.py -dGTKAgg
If using another backend blitting will not be possible right now (I don't
know ehy, I'm not very keen on this "manifold of backends" - I'm happy that
I got this running for GTKAgg and don't know why it is not working for
WXAgg).

If the position of the mousecklick and the actual position should be linked
by a straight line or a box (or none of both) can be set (e.g.
drawstyle='box').

Although this works fine for my belongings I'm still unhappy with two
things:
- All this doesn't look like the normal connect('event',function)-style. It
would be nicer if this LineSelector could also be handled in such a way.
- If one uses this LineSelector the callback-function has to accept exactly
two lenght-2 arays of floats (which means it is prescribed to the user). I'm
not quite sure if this is very practical.

Nice weekend,
Martin

LineSelector.py (8.03 KB)

···

--
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse f�r Mail, Message, More +++

I am a new user to MatPlotLib so some of the way it works is unfamiliar to me.
However I searched the archives and couldn't find anything like the problem I am having.
I hope someone has a work around or can tell me what is going on.

I have OS X 10.4.2, Python 2.4.1 framework build
I installed matplotlib 0.83.2 from source with freetype 2.10 from source
I fixed the bug in matplotlib in the font manager where the exception handling was commented out.
(BTW I had the same problem with a package install of matplotlib 0.82, I installed 0.83.2 hoping that
it would fix my problem)

When I save graphs in either .eps or .ps, I can't convert them to .pdf.
I tried using Adobe Distiller 7.0
Apple Preview
epstopdf

I believe the problem is that the postscript font definitions are bad. If I generate a plot without any text on the plot
then I can convert just fine to pdf.

Has anyone else experienced this problem?
Has anyone tried to convert to pdf? If you were successful what versions of the relevant software were you using
Is it just my setup or is the postscript generation code for font definitions broken?
Does anyone have suggestions for a workaround?

I posted this to sourceforge a couple of days ago but so far it doesn't appear that anyone has looked at it.

The error is as follows:

Acrobat Distiller 7.0
Started: Wednesday, 31 August, 2005 at 22:27
Adobe PostScript software version: 3016.102
CID support library initialization completed.

Distilling: test.ps
Start Time: Wednesday, 31 August, 2005 at 22:27
Source: /Users/smithsm/Data/Graphics/AWACS/plots/test.ps
Destination: /Users/smithsm/Data/Graphics/AWACS/plots/test.pdf
Adobe PDF Settings: /Library/Application Support/Adobe PDF/Settings/PYLab.joboptions
Processing prologue.ps...
Done processing prologue.ps.
%%[ Error: syntaxerror; OffendingCommand: > ]%%

Stack:
0
-mark-
/sfnts

%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
%%[ Warning: PostScript error. No PDF file produced. ] %%
Distill Time: 1 seconds (00:00:01)
**** End of Job ****

The offending command is in one of the font definitions

snip

%%BeginFont: ArialMT
%!PS-TrueType-0.1--32768.2
8 dict begin
/FontName /ArialMT def
/FontMatrix [1 0 0 1 0 0] def
/FontType 42 def
/Encoding StandardEncoding def
/FontBBox [-455 -431 2048 1869] def
/PaintType 0 def
/FontInfo 7 dict dup begin
/Notice (Typeface © The Monotype Corporation plc. Data © The Monotype Corporation plc/Type Solutions Inc. 1990-1992. All Rights Reserved) def
/FamilyName (Arial) def
/FullName (Arial) def
/version (Version 2.60) def
/isFixedPitch false def
/UnderlinePosition -217 def
/UnderlineThickness 150 def
end readonly def
/sfnts [
00>
] def
/CharStrings 242 dict dup begin

end snip

typo its freetype 2.1.10

···

On 02 Sep, 2005, at 08:06, Samuel M. Smith wrote:

I am a new user to MatPlotLib so some of the way it works is unfamiliar to me.
However I searched the archives and couldn't find anything like the problem I am having.
I hope someone has a work around or can tell me what is going on.

I have OS X 10.4.2, Python 2.4.1 framework build
I installed matplotlib 0.83.2 from source with freetype 2.10 from source

Samuel M. Smith wrote:

When I save graphs in either .eps or .ps, I can't convert them to .pdf.
I tried using Adobe Distiller 7.0
Apple Preview
epstopdf

I believe the problem is that the postscript font definitions are bad.
If I generate a plot without any text on the plot
then I can convert just fine to pdf.

Has anyone else experienced this problem?

Yes. If you have LaTeX installed, and set

  rc('text', usetex=True)

then saving to EPS and converting to PDF through any of the various
means works fine.

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
  -- Richard Harter

Yes. If you have LaTeX installed, and set

  rc('text', usetex=True)

then saving to EPS and converting to PDF through any of the various
means works fine.

I installed the latest version of TexShop and then tried it.
It worked. Thanks!

However when I set usetex=True in my matplotlibrc file it does not use tex. I have to manually call
rc('text',usetex=True) inside python, do you know why it does not work from the rc file?

Do I need to delete my font cache? or is something else overriding it in the rc file.

With usetex = true, a serif font is used. How to I get matplotlib to use a sans serif font?
I assume I need to change the font.latex.package but I don't know what my choices are.

this is my rc file section

ont.family : sans-serif
font.style : normal
font.variant : normal
font.weight : medium
font.stretch : normal
font.size : medium
font.serif : New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Bitstream Vera Serif, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
font.sans-serif : Lucida Grande, Verdana, Geneva, Lucida, Bitstream Vera Sans, Arial, Helvetica, sans-serif
font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, cursive
font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, fantasy
font.monospace : Andale Mono, Bitstream Vera Sans Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace
font.latex.package : type1cm # This must be an available LaTeX font
#package, like 'times' or 'pslatex' ; only applies if text.usetex is set

> Yes. If you have LaTeX installed, and set
>
> rc('text', usetex=True)
>
> then saving to EPS and converting to PDF through any of the various
> means works fine.

I installed the latest version of TexShop and then tried it.
It worked. Thanks!

However when I set usetex=True in my matplotlibrc file it does not
use tex. I have to manually call
rc('text',usetex=True) inside python, do you know why it does not
work from the rc file?

The only reason I can think of is that your rc file is stored where mpl can't
find it, or, you have another rc file somewhere that is being read before the
one you are editing.

With usetex = true, a serif font is used. How to I get matplotlib to
use a sans serif font?
I assume I need to change the font.latex.package but I don't know
what my choices are.

I'm afraid I'm going to have to defer you to the web for available font
packages. Maybe ask a tex newsgroup...

Darren

···

On Thursday 08 September 2005 11:58 pm, Samuel M.Smith wrote:

Samuel M.Smith wrote:

With usetex = true, a serif font is used. How to I get matplotlib to
use a sans serif font?
I assume I need to change the font.latex.package but I don't know what
my choices are.

I don't think so. LaTeX font packages specify one each of serif,
sans-serif, and typewriter faces[1]. The problem is that matplotlib's
generated LaTeX doesn't seem to honor the font.family selection.

You can add something like this at the top of TexManager.get_tex_command():

fontcmd = {'sans-serif': r'{\sffamily %s}',
           'monospace': r'{\ttfamily %s}'}.get(rcParams['font.family'],
                                               r'{\rmfamily %s}')
tex = fontcmd % tex

[1] But to find which font packages you have installed, go to
/usr/local/share/texmf/tex/latex/ (replace /usr/local with whatever the
prefix is for your TeX installation; also "texmf" may be something
similar like "texmf-dist" in DarwinPorts). Then

  $ ls */*.fd

I think all of those directories that have .fd files in them are font
packages. The package name will be the same as the directory name, I
believe.

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
  -- Richard Harter

However when I set usetex=True in my matplotlibrc file it does not
use tex. I have to manually call
rc('text',usetex=True) inside python, do you know why it does not
work from the rc file?

The only reason I can think of is that your rc file is stored where mpl can't
find it, or, you have another rc file somewhere that is being read before the
one you are editing.

When I switched from matplotlib 0.82 to 0.83.2 I had problems and had to revert back to 0.82 until I found
a fix for the problems. Everytime I installed 0.83.2 it would move my .matplotlibrc file into .matplotlib/matplotlibrc.
When I reinstalled 0.83.2 I had to manually move the rc file back out of the .matplotlibrc directory. I made a backup
of .matplotlibrc and stupidly called it matplotlibrc. It appears that 0.83.2 will first look for matplotlibrc in your home directory and then if it doesn't find it there look for matplotlibrc in ~/.matplotlib/matplotlibrc. Once I renamed the matplotlibrc in my home folder the changes I made to select tex in the ~/.matplotlib/matplotlib showed up.

Thanks.

Thanks Robert. I made the changes to texmanager.py and it worked.

···

On 08 Sep, 2005, at 23:24, Robert Kern wrote:

Samuel M.Smith wrote:

With usetex = true, a serif font is used. How to I get matplotlib to
use a sans serif font?
I assume I need to change the font.latex.package but I don't know what
my choices are.

I don't think so. LaTeX font packages specify one each of serif,
sans-serif, and typewriter faces[1]. The problem is that matplotlib's
generated LaTeX doesn't seem to honor the font.family selection.

You can add something like this at the top of TexManager.get_tex_command():

fontcmd = {'sans-serif': r'{\sffamily %s}',
           'monospace': r'{\ttfamily %s}'}.get(rcParams['font.family'],
                                               r'{\rmfamily %s}')
tex = fontcmd % tex

[1] But to find which font packages you have installed, go to
/usr/local/share/texmf/tex/latex/ (replace /usr/local with whatever the
prefix is for your TeX installation; also "texmf" may be something
similar like "texmf-dist" in DarwinPorts). Then

  $ ls */*.fd

I think all of those directories that have .fd files in them are font
packages. The package name will be the same as the directory name, I
believe.

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
  -- Richard Harter

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

**********************************************************************
Samuel M. Smith Ph.D.
2966 Fort Hill Road
Eagle Mountain, Utah 84043
801-768-2768 voice
801-768-2769 fax
**********************************************************************
"The greatest source of failure and unhappiness in the world is
giving up what we want most for what we want at the moment"
**********************************************************************