Re: [matplotlib-devel] colorbar edges in white for PDF output

2012-11-01 Thread Andrew Dawson
I used git bisect to work out where this first happens and it says
https://github.com/matplotlib/matplotlib/commit/4dd3de1b580ac0d7dc53bcca396ba1bf25a8eea9is
the first bad commit. This commit does make changes to the PDF backend
so it seems feasible. Unfortunately I don't know the backend code so this
is currently out of my depth...

Perhaps Michael could weigh in on this? Or others familiar with backend
workings?

Andrew


On 31 October 2012 16:29, Nicolas Rougier  wrote:

>
> I confirm on 1.2.x. on OSX 10.7.5.
>
> Nicolas
>
>
> On Oct 31, 2012, at 17:20 , Andrew Dawson wrote:
>
> > Hi all,
> >
> > I just noticed that colorbar edges are drawn in white when output in PDF
> and black when output in PNG. A small test script is attached along with
> the output to show the difference.
> >
> > I'd be interested in knowing if others can reproduce this? I'm using
> mpl-1.3.x (updated 5 minutes ago) on 64-bit Ubuntu 12.04.
> >
> > Cheers,
> > Andrew
> >
> --
> > Everyone hates slow websites. So do we.
> > Make your web apps faster with AppDynamics
> > Download AppDynamics Lite for free today:
> >
> http://p.sf.net/sfu/appdyn_sfd2d_oct___
> > Matplotlib-devel mailing list
> > Matplotlib-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
>
--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Animation class: let save() accept **kwargs which are passed on to savefig()?

2012-11-01 Thread Maximilian Albert
Hi all,

quick update on this: I pushed a small change to make the default
argument immutable (thanks to Jens for pointing this out). Just a
couple more questions/comments:

1) Should there be a test for this? I couldn't find any tests for the
Animation class, so I haven't added one. But perhaps I just missed
them.

2) I discovered this morning that my change uncovers/introduces a bug
in the Animation class, so I'd appreciate a bit more input on whether
it should be merged in the current state. Here is an explanation:

My original use case the suggested change was to be able to set tight
bounding boxes when saving animation frames. At the time I simply
saved all frames to separate images and combined them manually using
avconv, which worked fine. I saw that in the development version of
matplotlib there is built-in support for this, so that the video file
is created automatically. Now whenever I change the bounding box, e.g.
by passing something like savefig_kwargs={'bbox_inches': 'tight'} to
Animation.save(), then the output video shows complete garbage
(similar to white noise). I presume this is because the 'frame_size'
property in the MovieWriter class is not aware of the bounding box
changes introduced by savefig_kwargs and thus reports a frame size to
the video converter that is different from the actual size of the
saved frames.

I don't have much time to look into this at the moment, but I just
wanted to point it out. Does anyone have a quick idea for a good fix,
before I get the time to look into the details of how the MovieWriter
class works?

Many thanks,
Max


2012/10/31 Maximilian Albert :
> Awesome, many thanks for the detailed instructions, as well as for the
> valuable suggestions by Eric and Jens. I have now created a pull
> request containing the proposed change, including the suggested
> modifications:
>
>https://github.com/matplotlib/matplotlib/pull/1442
>
> Any comments/feedback would be much appreciated.
>
> Best wishes,
> Max
>
>
> 2012/10/31 Damon McDougall :
>> On Wed, Oct 31, 2012 at 7:40 AM, Maximilian Albert
>>  wrote:
>>> Hi Damon,
>>>
>>> many thanks for the quick (and positive :)) reply,
>>>
 Sounds like a great idea! Would you feel comfortable having a go at an
 implementation? You can make a pull request out of it. The rest of the
 developers can then deliberate and provide feedback for you.
>>>
>>> I attached a patch to my previous email which contains an
>>> implementation, but perhaps it didn't make it through to the list? But
>>> since I had to clone the git repository anyway to implement it, I'm
>>> happy to make a pull request, too. I'll have to find out how to do
>>> that since I've never done it before, but I guess it can't be too
>>> difficult. Will give it a shot later today.
>>
>> You need to fork the main matplotlib repo, so you have your own copy
>> associated with your github account:
>> https://help.github.com/articles/fork-a-repo
>>
>> Once you've forked it, clone it and create a branch:
>>
>> git clone my-forked-repo-url
>> cd matplotlib
>> git checkout -b my_awesome_new_feature
>> # ... hack hack hack ...
>> git commit -am "Useful commit message here"
>> git push origin my_awesome_new_feature
>>
>> Once you've done that, make a pull request by following the
>> instructions here:
>> https://help.github.com/articles/using-pull-requests
>>
>> Once you've done that, congratulations!
>>
>> Hope this helps.
>> Best wishes,
>> Damon
>>
>> --
>> Damon McDougall
>> http://www.damon-is-a-geek.com
>> B2.39
>> Mathematics Institute
>> University of Warwick
>> Coventry
>> West Midlands
>> CV4 7AL
>> United Kingdom

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] colorbar edges in white for PDF output

2012-11-01 Thread Michael Droettboom

I've filed an issue for this here:

https://github.com/matplotlib/matplotlib/issues/1444

Mike

On 10/31/2012 12:20 PM, Andrew Dawson wrote:

Hi all,

I just noticed that colorbar edges are drawn in white when output in 
PDF and black when output in PNG. A small test script is attached 
along with the output to show the difference.


I'd be interested in knowing if others can reproduce this? I'm using 
mpl-1.3.x (updated 5 minutes ago) on 64-bit Ubuntu 12.04.


Cheers,
Andrew

bug.py


import matplotlib.pyplot as plt
import numpy as np

# dummy data
x = y = np.linspace(-np.pi, np.pi, 50)
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(2.*Y)

# draw a filled contour plot and add a colorbar with drawedges turned on
contours = plt.contourf(x, y, Z)
cb = plt.colorbar(orientation='horizontal', drawedges=True)

# turn off tick marks so the edges can be seen
for tick in cb.ax.get_xticklines() + cb.ax.get_yticklines():
 tick.set_visible(False)

# save as a PDF and a PNG
plt.savefig('test.pdf')
plt.savefig('test.png')



--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Animation class: let save() accept **kwargs which are passed on to savefig()?

2012-11-01 Thread Ryan May
On Thu, Nov 1, 2012 at 5:38 AM, Maximilian Albert
 wrote:
> Hi all,
>
> quick update on this: I pushed a small change to make the default
> argument immutable (thanks to Jens for pointing this out). Just a
> couple more questions/comments:
>
> 1) Should there be a test for this? I couldn't find any tests for the
> Animation class, so I haven't added one. But perhaps I just missed
> them.

Sadly there are no tests. Partially because I'm lazy, and partially
because I'm not sure how exactly that would work. I'd gladly take a PR
with some if someone can figure it out, but I realize that's more than
you signed up for.

> 2) I discovered this morning that my change uncovers/introduces a bug
> in the Animation class, so I'd appreciate a bit more input on whether
> it should be merged in the current state. Here is an explanation:
>
> My original use case the suggested change was to be able to set tight
> bounding boxes when saving animation frames. At the time I simply
> saved all frames to separate images and combined them manually using
> avconv, which worked fine. I saw that in the development version of
> matplotlib there is built-in support for this, so that the video file
> is created automatically. Now whenever I change the bounding box, e.g.
> by passing something like savefig_kwargs={'bbox_inches': 'tight'} to
> Animation.save(), then the output video shows complete garbage
> (similar to white noise). I presume this is because the 'frame_size'
> property in the MovieWriter class is not aware of the bounding box
> changes introduced by savefig_kwargs and thus reports a frame size to
> the video converter that is different from the actual size of the
> saved frames.
>
> I don't have much time to look into this at the moment, but I just
> wanted to point it out. Does anyone have a quick idea for a good fix,
> before I get the time to look into the details of how the MovieWriter
> class works?

You might have more luck using a temp-file based writer. By default,
movies are created by piping in the data to the command; this is much
faster, but, at least as I've done it now, requires a fixed number of
bytes per frame. Try passing writer='ffmpeg_file' or
writer='mencoder_file' to the command to save the animation.

If I get a chance (or someone else if you want to help), I'll see if
there's any way to make the pipe-based writers work with
variable-sized frames. Failing that, we could just ignore the tight
bbox option when using pipes for saving movies.

Thanks for the work!

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] colorbar edges in white for PDF output

2012-11-01 Thread Michael Droettboom
I now have a fix attached to that issue.  Andrew: can you confirm it 
works for you?


Mike

On 11/01/2012 09:06 AM, Michael Droettboom wrote:

I've filed an issue for this here:

https://github.com/matplotlib/matplotlib/issues/1444

Mike

On 10/31/2012 12:20 PM, Andrew Dawson wrote:

Hi all,

I just noticed that colorbar edges are drawn in white when output in 
PDF and black when output in PNG. A small test script is attached 
along with the output to show the difference.


I'd be interested in knowing if others can reproduce this? I'm using 
mpl-1.3.x (updated 5 minutes ago) on 64-bit Ubuntu 12.04.


Cheers,
Andrew

bug.py


import matplotlib.pyplot as plt
import numpy as np

# dummy data
x = y = np.linspace(-np.pi, np.pi, 50)
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(2.*Y)

# draw a filled contour plot and add a colorbar with drawedges turned on
contours = plt.contourf(x, y, Z)
cb = plt.colorbar(orientation='horizontal', drawedges=True)

# turn off tick marks so the edges can be seen
for tick in cb.ax.get_xticklines() + cb.ax.get_yticklines():
 tick.set_visible(False)

# save as a PDF and a PNG
plt.savefig('test.pdf')
plt.savefig('test.png')





--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct


___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] colorbar edges in white for PDF output

2012-11-01 Thread Andrew Dawson
It is possible I have spoken too soon. It certainly fixes the specific
issue I was having, however I am now getting serious issues with a plot
that uses the basemap toolkit. The contours and coastlines extend way
beyond the plot boundaries. I've put links to before and after plots from
something I'm working on, I don't have time to do a clean test script
tonight though.

I don't know if this is a matplotlib issue or something to do with
basemap... some thought is probably required on this one.

http://dl.dropbox.com/u/4496818/bad.pdf
http://dl.dropbox.com/u/4496818/good.pdf

Andrew


On 1 November 2012 16:02, Andrew Dawson  wrote:

> Yes this seems to work for me.
>
>
> On 1 November 2012 15:25, Michael Droettboom  wrote:
>
>>  I now have a fix attached to that issue.  Andrew: can you confirm it
>> works for you?
>>
>> Mike
>>
>>
>> On 11/01/2012 09:06 AM, Michael Droettboom wrote:
>>
>> I've filed an issue for this here:
>>
>> https://github.com/matplotlib/matplotlib/issues/1444
>>
>> Mike
>>
>> On 10/31/2012 12:20 PM, Andrew Dawson wrote:
>>
>> Hi all,
>>
>>  I just noticed that colorbar edges are drawn in white when output in
>> PDF and black when output in PNG. A small test script is attached along
>> with the output to show the difference.
>>
>>  I'd be interested in knowing if others can reproduce this? I'm using
>> mpl-1.3.x (updated 5 minutes ago) on 64-bit Ubuntu 12.04.
>>
>>  Cheers,
>> Andrew
>>
>> bug.py
>>
>> import matplotlib.pyplot as plt
>> import numpy as np
>>
>> # dummy data
>> x = y = np.linspace(-np.pi, np.pi, 50)
>> X, Y = np.meshgrid(x, y)
>> Z = np.sin(X) * np.cos(2.*Y)
>>
>> # draw a filled contour plot and add a colorbar with drawedges turned on
>> contours = plt.contourf(x, y, Z)
>> cb = plt.colorbar(orientation='horizontal', drawedges=True)
>>
>> # turn off tick marks so the edges can be seen
>> for tick in cb.ax.get_xticklines() + cb.ax.get_yticklines():
>> tick.set_visible(False)
>>
>> # save as a PDF and a PNG
>> plt.savefig('test.pdf')
>> plt.savefig('test.png')
>>
>>
>>
>>
>>
>> --
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:http://p.sf.net/sfu/appdyn_sfd2d_oct
>>
>>
>>
>> ___
>> Matplotlib-devel mailing 
>> listMatplotlib-devel@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>
>>
>>
>>
>> --
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_sfd2d_oct
>> ___
>> Matplotlib-devel mailing list
>> Matplotlib-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>
>>
>
>
> --
> Dr Andrew Dawson
> Atmospheric, Oceanic & Planetary Physics
> Clarendon Laboratory
> Parks Road
> Oxford OX1 3PU, UK
> Tel: +44 (0)1865 282438
> Email: daw...@atm.ox.ac.uk
> Web Site: http://www2.physics.ox.ac.uk/contacts/people/dawson
>
>
--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] colorbar edges in white for PDF output

2012-11-01 Thread Michael Droettboom
Thanks.  I think the clipping is getting thrown away by what I just 
did.  It should be an easy fix.


Mike

On 11/01/2012 01:59 PM, Andrew Dawson wrote:
It is possible I have spoken too soon. It certainly fixes the specific 
issue I was having, however I am now getting serious issues with a 
plot that uses the basemap toolkit. The contours and coastlines extend 
way beyond the plot boundaries. I've put links to before and after 
plots from something I'm working on, I don't have time to do a clean 
test script tonight though.


I don't know if this is a matplotlib issue or something to do with 
basemap... some thought is probably required on this one.


http://dl.dropbox.com/u/4496818/bad.pdf
http://dl.dropbox.com/u/4496818/good.pdf

Andrew


On 1 November 2012 16:02, Andrew Dawson > wrote:


Yes this seems to work for me.


On 1 November 2012 15:25, Michael Droettboom mailto:md...@stsci.edu>> wrote:

I now have a fix attached to that issue. Andrew: can you
confirm it works for you?

Mike


On 11/01/2012 09:06 AM, Michael Droettboom wrote:

I've filed an issue for this here:

https://github.com/matplotlib/matplotlib/issues/1444

Mike

On 10/31/2012 12:20 PM, Andrew Dawson wrote:

Hi all,

I just noticed that colorbar edges are drawn in white when
output in PDF and black when output in PNG. A small test
script is attached along with the output to show the difference.

I'd be interested in knowing if others can reproduce this?
I'm using mpl-1.3.x (updated 5 minutes ago) on 64-bit Ubuntu
12.04.

Cheers,
Andrew

bug.py


import matplotlib.pyplot as plt
import numpy as np

# dummy data
x = y = np.linspace(-np.pi, np.pi, 50)
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(2.*Y)

# draw a filled contour plot and add a colorbar with drawedges turned on
contours = plt.contourf(x, y, Z)
cb = plt.colorbar(orientation='horizontal', drawedges=True)

# turn off tick marks so the edges can be seen
for tick in cb.ax.get_xticklines() + cb.ax.get_yticklines():
 tick.set_visible(False)

# save as a PDF and a PNG
plt.savefig('test.pdf')
plt.savefig('test.png')






--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct


___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net  

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel




--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel




-- 
Dr Andrew Dawson

Atmospheric, Oceanic & Planetary Physics
Clarendon Laboratory
Parks Road
Oxford OX1 3PU, UK
Tel: +44 (0)1865 282438 
Email: daw...@atm.ox.ac.uk 
Web Site: http://www2.physics.ox.ac.uk/contacts/people/dawson




--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] colorbar edges in white for PDF output

2012-11-01 Thread Michael Droettboom

Can you try https://github.com/matplotlib/matplotlib/pull/1446?

Mike

On 11/01/2012 01:59 PM, Andrew Dawson wrote:
It is possible I have spoken too soon. It certainly fixes the specific 
issue I was having, however I am now getting serious issues with a 
plot that uses the basemap toolkit. The contours and coastlines extend 
way beyond the plot boundaries. I've put links to before and after 
plots from something I'm working on, I don't have time to do a clean 
test script tonight though.


I don't know if this is a matplotlib issue or something to do with 
basemap... some thought is probably required on this one.


http://dl.dropbox.com/u/4496818/bad.pdf
http://dl.dropbox.com/u/4496818/good.pdf

Andrew


On 1 November 2012 16:02, Andrew Dawson > wrote:


Yes this seems to work for me.


On 1 November 2012 15:25, Michael Droettboom mailto:md...@stsci.edu>> wrote:

I now have a fix attached to that issue. Andrew: can you
confirm it works for you?

Mike


On 11/01/2012 09:06 AM, Michael Droettboom wrote:

I've filed an issue for this here:

https://github.com/matplotlib/matplotlib/issues/1444

Mike

On 10/31/2012 12:20 PM, Andrew Dawson wrote:

Hi all,

I just noticed that colorbar edges are drawn in white when
output in PDF and black when output in PNG. A small test
script is attached along with the output to show the difference.

I'd be interested in knowing if others can reproduce this?
I'm using mpl-1.3.x (updated 5 minutes ago) on 64-bit Ubuntu
12.04.

Cheers,
Andrew

bug.py


import matplotlib.pyplot as plt
import numpy as np

# dummy data
x = y = np.linspace(-np.pi, np.pi, 50)
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(2.*Y)

# draw a filled contour plot and add a colorbar with drawedges turned on
contours = plt.contourf(x, y, Z)
cb = plt.colorbar(orientation='horizontal', drawedges=True)

# turn off tick marks so the edges can be seen
for tick in cb.ax.get_xticklines() + cb.ax.get_yticklines():
 tick.set_visible(False)

# save as a PDF and a PNG
plt.savefig('test.pdf')
plt.savefig('test.png')






--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct


___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net  

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel




--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel




-- 
Dr Andrew Dawson

Atmospheric, Oceanic & Planetary Physics
Clarendon Laboratory
Parks Road
Oxford OX1 3PU, UK
Tel: +44 (0)1865 282438 
Email: daw...@atm.ox.ac.uk 
Web Site: http://www2.physics.ox.ac.uk/contacts/people/dawson




--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel