markeredgewidth and pdf

Hi List,

With mpl 0.91.2, the markeredgewidth property does not seem to have an effect when using the pdf backend (seems to always be 1, regardless of what I set it to, and it seems to be fine with other backends). Here is a minimal example:

from matplotlib import use
#use('pdf') # <- Uncomment for pdf

import matplotlib.pyplot as plt
hf=plt.plot([1,2],[1,1],marker='o',mfc='white', ms=12, mew=4, ls="None")
plt.xlim(.5,2.5)
plt.savefig("c:\\test")

···

--
Chris

Christopher Brown wrote:

With mpl 0.91.2, the markeredgewidth property does not seem to have an effect when using the pdf backend (seems to always be 1, regardless of what I set it to, and it seems to be fine with other backends). Here is a minimal example:

Interestingly, the error only shows up in the pdf viewer foxit (what I happened to be using at the time). Other viewers display the markers properly. Although it is still unclear to me whether it is an mpl/pdf-backend error or a foxit rendering error.

Sorry to trouble you all.

It's worth noting -- these viewer differences do pop up from time to time. Since I don't have Foxit (or Windows) installed, I wonder if you could run an experiment. If you generate the PDF with mpl's Cairo backend, do you see the same behavior? If not, we can analyse the differences in the PDFs and possibly come up with a solution that will work.

Cheers,
Mike

Christopher Brown wrote:

···

Christopher Brown wrote:
  

With mpl 0.91.2, the markeredgewidth property does not seem to have an effect when using the pdf backend (seems to always be 1, regardless of what I set it to, and it seems to be fine with other backends). Here is a minimal example:
    
Interestingly, the error only shows up in the pdf viewer foxit (what I happened to be using at the time). Other viewers display the markers properly. Although it is still unclear to me whether it is an mpl/pdf-backend error or a foxit rendering error.

Sorry to trouble you all.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Hi Mike,

It's worth noting -- these viewer differences do pop up from time to
time. Since I don't have Foxit (or Windows) installed, I wonder if
you could run an experiment. If you generate the PDF with mpl's
Cairo backend, do you see the same behavior? If not, we can
analyse the differences in the PDFs and possibly come up with a
solution that will work.

I'm having real difficulty getting the cairo backend installed. If
anyone has any experience with pkg-config and windows, please let me
know. Specifically, I get the error:

Package 'cairo was not found in the pkg-config search path. Perhaps you
should add the directory containing `'cairo.pc' to the PKG_CONFIG_PATH
environment variable

...although I have, in fact, created this environment variable in windows.

Anyway, I have created a pdf using the wxagg backend, which yields the same result (markeredgewidth is always 1 when viewing with foxit). I will create a figure tonight from home (kubuntu) using the cairo backend, then examine it tomorrow at work (windows/foxit) and report back.

···

--
Christopher Brown, Ph.D.
Department of Speech and Hearing Science
Arizona State University

Christopher Brown wrote:

Hi Mike,

> It's worth noting -- these viewer differences do pop up from time to
> time. Since I don't have Foxit (or Windows) installed, I wonder if
> you could run an experiment. If you generate the PDF with mpl's
> Cairo backend, do you see the same behavior? If not, we can
> analyse the differences in the PDFs and possibly come up with a
> solution that will work.

I'm having real difficulty getting the cairo backend installed. If
anyone has any experience with pkg-config and windows, please let me
know. Specifically, I get the error:

Package 'cairo was not found in the pkg-config search path. Perhaps you
should add the directory containing `'cairo.pc' to the PKG_CONFIG_PATH
environment variable

...although I have, in fact, created this environment variable in windows.
  

I can't be of much help with Windows builds, unfortunately. However, for clarification, is this error from building pycairo or matplotlib? matplotlib *should* be able to bypass pkg-config if it isn't available.

Anyway, I have created a pdf using the wxagg backend, which yields the same result (markeredgewidth is always 1 when viewing with foxit).

That uses the same PDF code path, so not surprising.

I will create a figure tonight from home (kubuntu) using the cairo backend, then examine it tomorrow at work (windows/foxit) and report back.

Sounds like a good experiment. Thanks for helping out.

Cheers,
Mike

···

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Hi Michael,

I can't be of much help with Windows builds, unfortunately.
However, for clarification, is this error from building pycairo or
matplotlib? matplotlib *should* be able to bypass pkg-config if it
isn't available.

The error occurred while building pycairo.

> will create a figure tonight from home (kubuntu) using the cairo
> backend, then examine it tomorrow at work (windows/foxit) and
> report back.
>
Sounds like a good experiment. Thanks for helping out.

With a plot made using the cairo backend, the markers render correctly in foxit. I am standing by for further instruction. :slight_smile:

By the way, I'm using mpl from svn.

···

--
Chris

In matplotlib's Python PDF backend, each marker type is stored in an XObject (a reusable object) only once, and referenced to draw each to the screen. The Cairo backend does not have this optimization and draws each marker independently. It would seem that Foxit does not use the current graphics context (pen width etc.) when referencing XObjects.

The PDF Spec (version 1.7) has this to say (emphasis mine):

    A form XObject is a PDF content stream that is a self-contained
    description of any sequence of graphics objects (including path
    objects, text objects, and sampled images). A form XObject may be
    painted multiple times�either on several pages or at several
    locations on the same page�and produces the same results each time,
    /subject only to the graphics state at the time it is invoked/. Not
    only is this shared definition economical to represent in the PDF
    file, but under suitable circumstances the PDF consumer application
    can optimize execution by caching the results of rendering the form
    XObject for repeated reuse.

So --- this would appear to be a bug in Foxit. Perhaps you could submit this problematic PDF to them.

We could fairly easily provide a workaround by not doing this optimization (I've attached a PDF so you can verify that it solves the Foxit issue). But it is an important optimization when there are hundreds of markers in a plot. We could make this user-configurable, but I'm wary of adding more config parameters without really good reasons -- many user issues on this list come down to someone using a particular configuration that a developer neglected to test with.

What do others here think?

Cheers,
Mike

Christopher Brown wrote:

test3.pdf (10 KB)

···

Hi Michael,

> I can't be of much help with Windows builds, unfortunately.
> However, for clarification, is this error from building pycairo or
> matplotlib? matplotlib *should* be able to bypass pkg-config if it
> isn't available.

The error occurred while building pycairo.

> > will create a figure tonight from home (kubuntu) using the cairo
> > backend, then examine it tomorrow at work (windows/foxit) and
> > report back.
> >
> Sounds like a good experiment. Thanks for helping out.

With a plot made using the cairo backend, the markers render correctly in foxit. I am standing by for further instruction. :slight_smile:

By the way, I'm using mpl from svn.

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Hi Mike,

Your test pdf shows up properly in Foxit.

So --- this would appear to be a bug in Foxit. Perhaps you could
submit this problematic PDF to them.

I will do so, and I'll also include your description of the problem.

···

--
Chris