[Matplotlib-users] bug in saving figure with dashed lines

2006-08-01 Thread Eric Emsellem
Hi,
I just produced a plot with a curve dashed line:

when saving it into a png file it works fine.
But when saving it in a postscript the dashed line looks solid on most
of the plot.
This happens if there are too many points in the line:

x = arange(0,1.,0.0001)
y = sqrt(x)
plot(x,y,'k--')
## Png file is ok
savefig("toto.png")
## Eps file is NOT ok
savefig("toto.eps")

Any cure to that behaviour?

Thanks!!!
Eric

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] bug in saving figure with dashed lines

2006-08-01 Thread Jouni K Seppanen
Eric Emsellem <[EMAIL PROTECTED]> writes:

> But when saving it in a postscript the dashed line looks solid on most
> of the plot.
> This happens if there are too many points in the line:

The draw_lines method in the PS backend divides the line into
subsequences of at most 50 points, and calls the "stroke" operator for
each subsequence, which in effect resets the dash offset. Thus if 50
consecutive points fit within a dash, the line appears solid.

I suppose the division into subsequences solves some memory or speed
problem with PS interpreters, so it should be retained. Then the
solution would be to compute the length X of each subsequence and do
something like "currentdash pop X setdash" after the "stroke".

-- 
Jouni


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Combining figures

2006-08-01 Thread John Hunter
> "David" == David Huard <[EMAIL PROTECTED]> writes:

David> Hi John, Thanks for taking the time to answer a badly
David> formulated question. With your indications, I have been
David> able to get an example working.

Great.

David> s1.set_xlim(s2.get_xlim()) 

There is a nice little trick where you can make two axes share the
same xaxis.  Then when you pan or zoom on one, the other is
automagically changed to

ax1 = subplot(211)
ax2 = subplot(212, sharex=ax1)

Ditto for sharey.  A very useful trick!

JDH

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] bug in saving figure with dashed lines

2006-08-01 Thread John Hunter
> "Jouni" == Jouni K Seppanen <[EMAIL PROTECTED]> writes:
Jouni> The draw_lines method in the PS backend divides the line
Jouni> into subsequences of at most 50 points, and calls the
Jouni> "stroke" operator for each subsequence, which in effect
Jouni> resets the dash offset. Thus if 50 consecutive points fit
Jouni> within a dash, the line appears solid.

50 seems awfully small to me.  There are maximum length path
limitations of some postscript interpreters which is why we batch
these up.  Darren, could we get away with a step of 1000 here rather
than 50?

JDH

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Combining figures

2006-08-01 Thread David Huard
There is a nice little trick where you can make two axes share the
same xaxis.  Then when you pan or zoom on one, the other isautomagically changed toax1 = subplot(211)ax2 = subplot(212, sharex=ax1)But that's not retroactive, or is it ? i.e. if ax2 has a wider x range than ax1, it won't show up.
f = figure(1)s1 = subplot(211)s1.plot([1,2,3], [1,2,3])s2 = subplot(212, sharex = s1)s2.plot([4,5,6], [1,2,3])
I came up with the following function to solve that problem. Is there a more elegant solution?

def uniform_limits(axes, xrange = 'widest', yrange = 'widest'):
    """For all axes, sets xlim and ylim to the widest (shortest) range."""
    x = []
    y = []
    for ax in axes:
    x.append(ax.get_xlim())
    y.append(ax.get_ylim())
    x = vstack(asarray(x))
    y = vstack(asarray(y))
    if xrange == 'widest':
    xlims = x.min(0)[0], x.max(0)[1]    
    elif xrange == 'shortest':
    xlims = x.max(0)[0], x.min(0)[1]
    if yrange == 'widest':
    ylims = y.min(0)[0], y.max(0)[1]
    elif yrange == 'shortest':
    ylims = y.max(0)[0], y.min(0)[1]
    setp(axes, 'xlim', xlims, 'ylim', ylims)    
 David
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] bug in saving figure with dashed lines

2006-08-01 Thread Darren Dale
On Tuesday 01 August 2006 08:52, John Hunter wrote:
> > "Jouni" == Jouni K Seppanen <[EMAIL PROTECTED]> writes:
>
> Jouni> The draw_lines method in the PS backend divides the line
> Jouni> into subsequences of at most 50 points, and calls the
> Jouni> "stroke" operator for each subsequence, which in effect
> Jouni> resets the dash offset. Thus if 50 consecutive points fit
> Jouni> within a dash, the line appears solid.
>
> 50 seems awfully small to me.  There are maximum length path
> limitations of some postscript interpreters which is why we batch
> these up.  Darren, could we get away with a step of 1000 here rather
> than 50?

Here are GGV's render times for a line containing 1e6 points:

division | time (s)
50  3
10009
10  8
none28

I bumped it up to 100,000 in svn 2644, which seems to have improved the dash 
problem.

Darren

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users