Re: [matplotlib-devel] plot directive, thank you and a question

2010-11-09 Thread Matthew Brett
Hi,

On Mon, Nov 8, 2010 at 7:06 PM, John Hunter  wrote:
> On Mon, Nov 8, 2010 at 6:55 PM, Matthew Brett  wrote:
...
>> and so on.  I mean, the ability to keep the code context across the
>> page, both in the ..plot: and ..testcode:: and even >>> directives, so
>> I can build up my tutorial examples on top of the previous results.
>> That step would make it the perfect tool for the tutorials that I have
>> ready to port - and I am sure - many others.
>>
>> Is that already possible?  If not, how easy would it be?  It if isn't
>> easy, can y'all give me some pointers as to how to get there?
>
> This is a useful feature I've wanted myself.  I just contributed a
> change to the plot directive in svn to support this using two new
> options :context: and :nofigs:, and updated the sampledoc tutorial.
> The relevant bit from the tutorial is in the link below:
>
>  http://matplotlib.sourceforge.net/sampledoc/extensions.html#inserting-matplotlib-plots
>
> Also, we have a really useful ipython directive that is stateful by
> default, and includes many options for suppressing input blocks,
> doctesting on output blocks, saving figures, and more.  It is included
> in the ipython src tree.  My original proposal is at
> http://matplotlib.sourceforge.net/ipymode/_build/html/proposal.html,
> which I've implemented with minor changes.  A real world working
> example from some lecture notes I prepared recently is attached as
> convolution.rst, and some notes are below.  I need to get this added
> to the sampledoc tutorial

Thanks for extensions, and the pointer to the ipython directive, I had
only half remembered it, but it does look very well designed for what
I had in mind.

For the first time for a few years, I'm looking forward to writing
some tutorials...

See you,

Matthew

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] event bug in polar axes

2010-11-09 Thread Michael Droettboom
On 11/08/2010 09:38 PM, Benjamin Root wrote:
>
> Thanks, that seems to do the trick.  What is it that one can do anyway
> with this pan/zoom mode?  All I seem to be able to do is move the
> labeling for the radial distance.
Right mouse button zooms the radial axis, analogously to how the right 
mouse button zooms axes in a rectilinear plot.

Mike

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Gaps between bars with pyplot.bar

2010-11-09 Thread Jeff Klukas
Hello developers,

I'm seeing what appears to be a bug when plotting bars next to each
other without edges.  In pdf output, you can see that there is a tiny
gap in between each bar, which renders as one pixel wide no matter how
far I zoom in.  It's also visible in interactive or png output:

http://www.dumpt.com/img/viewer.php?file=mc0wf07aksrzqs1h8j5k.png

You can generate the above by running a slightly modified demo:
---
#!/usr/bin/env python
# a stacked bar plot with errorbars
import numpy as np
import matplotlib.pyplot as plt


N = 5
menMeans   = (20, 35, 30, 35, 27)
womenMeans = (25, 32, 34, 20, 25)
menStd = (2, 3, 4, 1, 2)
womenStd   = (3, 5, 2, 3, 3)
ind = np.arange(N)# the x locations for the groups
width = 1.0   # CHANGED from 0.35 in the demo

# CHANGED: adding linewidth=0 to these calls
p1 = plt.bar(ind, menMeans,   width, color='r', yerr=womenStd, linewidth=0)
p2 = plt.bar(ind, womenMeans, width, color='y', linewidth=0,
 bottom=menMeans, yerr=menStd)

plt.ylabel('Scores')
plt.title('Scores by group and gender')
plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') )
plt.yticks(np.arange(0,81,10))
plt.legend( (p1[0], p2[0]), ('Men', 'Women') )

plt.show()
---

Any thoughts on why there's always a tiny gap between bars?

Thanks,
Jeff

|| Jeff Klukas
|| Physics Lecturer, University of Wisconsin -- Whitewater
|| Research Assistant, University of Wisconsin -- Madison
|| jeff.klu...@gmail | jeffyklu...@aim | jeffklu...@skype
|| http://hep.wisc.edu/~jklukas/

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] gtkagg w/o extension code

2010-11-09 Thread John Hunter
We are getting seg faults on our Solaris platform at work when we use
the blit API in GTKAgg.  This has been going on for a while, and I
don't know if it is in our pygtk version, or what.  The line that is
causing the crash is in src/_gtkagg.cpp

  GdkDrawable *drawable = GDK_DRAWABLE(py_drawable->obj);

But rather than spend any more time trying to track that down, I
decided to try and remove the gtk extension code entirely, which would
be a great help for building mpl and distributing binaries.  I feel
like I am close, but something is still not clicking (at least on my
platform).

I'm attaching an svn diff in case anyone has some ideas -- basically,
it removes the use of agg_to_gtk_drawable in
backend_gtkagg.FigureCanvasGTKAgg.blit and replaces it with gdk
pixmap/pixbuffer calls.  If anyone has any ideas, please let me know.

Attached also is the example code I am using to test.  Strangely, the
agg buffer seems to be updating internally but the gtk window is only
updating when I hover my mouse over it, and then only once until I
activate another window and then re-hover over the mpl animation
window.

Thanks for any help!
JDH


diff.out
Description: Binary data


animation_blit_gtk.py
Description: Binary data
--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] gtkagg w/o extension code

2010-11-09 Thread John Hunter
On Tue, Nov 9, 2010 at 2:25 PM, John Hunter  wrote:

> Attached also is the example code I am using to test.  Strangely, the
> agg buffer seems to be updating internally but the gtk window is only
> updating when I hover my mouse over it, and then only once until I
> activate another window and then re-hover over the mpl animation
> window.

OK, this was an example of how writing the email for help solves the
problem.  As soon as I described the strange updating behavior, it
triggered my memory about the expose event code in backend_gtk and
when I took a look at that I realized I need to draw to the window and
not the pixbuf as we do in _render_figure.  The revised diff is
attached.

So this email now is a patch review request, and importantly, can we
get rid of all gtk extension code?  There is now no need for
_gtkagg.cpp, and the only other piece is src/_backend_gdk.c which
provides pixbuf_get_pixels_array.  If we could get rid of this, which
is used for images and mathtext in the GDK backend, it would be a big
win for compilation and distribution.  Ideally, I would like to not
compile anything against a GUI, but so far we haven't been able to
figure out a way around TkAgg.  But removing GTK compile time
dependencies would be a good start.

If you are familiar with agg and/or gtk/gdk internals, please take a
look at my updated patch.  I am not double buffering as we are in
_render_figure, which seems appropriate for animation.  I am actually
a little confused about why we need so many buffers in the main draw
pipeline -- we have the agg buffer, the gtk pixbuf, the gdk pixmap,
and the gdk window.  Does anyone recall why we don't render directly
from the pixbuf to the window here?  My guess is that it is to handle
the expose event in backend_gtk efficiently, but we should be able to
do this from the pixbuf directly to the window  Or perhaps I'm
missing something.

I'm going to proceed with removing _gtkagg.cpp in the trunk, and I
think we should consider disabling default builds of _backend_gdk.c
(they could be enabled by a config option if we can't find a python
replacement for pixbuf_get_pixels_array)

JDH


diff.out
Description: Binary data


animation_blit_gtk.py
Description: Binary data
--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] gtkagg w/o extension code

2010-11-09 Thread Eric Firing
On 11/09/2010 11:03 AM, John Hunter wrote:
> On Tue, Nov 9, 2010 at 2:25 PM, John Hunter  wrote:
>

>
> I'm going to proceed with removing _gtkagg.cpp in the trunk, and I
> think we should consider disabling default builds of _backend_gdk.c
> (they could be enabled by a config option if we can't find a python
> replacement for pixbuf_get_pixels_array)
>

John,

Based on a very superficial look, I suspect we could eliminate 
pixbuf_get_pixels_array by using the function 
http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#function-gdk--pixbuf-new-from-data.

Eric

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] gtkagg w/o extension code

2010-11-09 Thread John Hunter
On Tue, Nov 9, 2010 at 3:48 PM, Eric Firing  wrote:
> On 11/09/2010 11:03 AM, John Hunter wrote:

> Based on a very superficial look, I suspect we could eliminate
> pixbuf_get_pixels_array by using the function
> http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#function-gdk--pixbuf-new-from-data.

Nice find -- this does the trick.  I was able to plug it into gdk
draw_image and draw_mathtext fairly painlessly.  I've now removed all
the gtk compile time dependencies in the attached patch against svn
HEAD.  Because this is a major change, I'm going to hold off
committing it to give you all a change to review and test, and I'll
test some more on a different platform when I get home.  But on
solaris python2.4, I have animations with blitting in gtkagg, images
and mathtext in GTK/GDK, so this is looking pretty good so far (all of
this was segfaulting before)

Because build_gtk and build_gtkagg are no longer config options, there
is a small change in the logic in how the default backend gets set.
Now gtkagg will be set as the default backend if check_for_gtk returns
True.  We may want to change this, since tkagg is a little friendlier
across shells.

JDH


diff.out
Description: Binary data
--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] gtkagg w/o extension code

2010-11-09 Thread John Hunter
On Tue, Nov 9, 2010 at 7:57 PM, Benjamin Root  wrote:
> I gave your latest patch a try and I noticed something odd while doing the
> animation examples.  I don't know if this is a result of my special desktop
> configuration.  I am using Ubuntu Netbook Remix, which uses Maxiumus to
> automatically maximize all windows that open (including matplotlib figure
> windows).
>
> When running some of the animations (not all of them), the chart is
> distorted and remains so after un-maximizing.  I have included some
> screenshots to show what I mean.  This isn't the first time that Maximus has
> caused issues for me, because it does break many developers' assumptions
> about their program windows.  I am not sure if the problem is limited to
> just Maximus, or if anybody else can reproduce my manually maximizing their
> windows.

Thanks for testing Ben -- I'm seeing some of these artifacts too, eg
on examples/animation/subplots.py.  I may be transposing a row/col
argument somewhere, which is easy to do.  Also, I'll have to dig into
the animations.py code a little more to make sure it is doing the
copy_from_bbox background after each draw event so that everything is
properly sized.  Since these examples worked fine before my changes,
though, it is pretty clear where the culprit is :-)

JDH

--
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel