Re: [Matplotlib-users] different PNG and PDF output...

2008-12-20 Thread Lebostein

OK, now it works! Thank you!

A little thing: the shadow of the legend box is not scaling with the dpi.
For example with 300 dpi I can't discover the shadow...
-- 
View this message in context: 
http://www.nabble.com/different-PNG-and-PDF-output...-tp21028686p21109783.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


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


Re: [Matplotlib-users] different PNG and PDF output...

2008-12-20 Thread Jae-Joon Lee
On Sat, Dec 20, 2008 at 6:02 PM, Lebostein lebost...@gmx.de wrote:
 A little thing: the shadow of the legend box is not scaling with the dpi.
 For example with 300 dpi I can't discover the shadow...

This also should be fixed in the maintenance branch and the trunk.
Thanks for reporting.

-JJ

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


Re: [Matplotlib-users] different PNG and PDF output...

2008-12-16 Thread jkitchin

I also observed this with eps output. The png looked fine, but the eps legend
was very large in my case.

j



Lebostein wrote:
 
 Hi,
 
 with the new version of matplotlib, the legend looks different in png and
 pdf!
 
 I could post examples, but you can look in the galery also:
 http://matplotlib.sourceforge.net/gallery.html
 
 for example the legend_demo3
 http://matplotlib.sourceforge.net/examples/pylab_examples/legend_demo3.html
 * PNG:
 http://matplotlib.sourceforge.net/_static/plot_directive/mpl_examples/pylab_examples/legend_demo3.hires.png
 * PDF:
 http://matplotlib.sourceforge.net/_static/plot_directive/mpl_examples/pylab_examples/legend_demo3.pdf
 
 You see in the png the lines are short and not vertically centered,
 padding between axes an legend text are ignored .. and so on
 

-- 
View this message in context: 
http://www.nabble.com/different-PNG-and-PDF-output...-tp21028686p21037465.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] different PNG and PDF output...

2008-12-16 Thread Jae-Joon Lee
I just found  my previous message was only sent to Lebostein.
Anyhow, here is my original meesage.

On Tue, Dec 16, 2008 at 10:38 AM, Jae-Joon Lee lee.j.j...@gmail.com wrote:
 Yes, I can see the  differences.
 Anyway, it seems to me the differences are primarily caused by
 different dpi, not by different backend.
 I guess the image in
 http://matplotlib.sourceforge.net/examples/pylab_examples/legend_demo3.html
 is also created with png backend, and that looks okay to me.
 And I'm afraid that I didn't correctly accounted the figure dpi when I
 calculate these dimensions.
 I'll try to correct this soon.

 Thanks.

 -JJ




And, Micheal, yes, it is a dpi issue. I was using font size in
points as a reference while it should be in pixels. This should be
fixed both in the maintenance branch and in the trunk.

So, Lebostein and j, if you know how  to check out using svn, can you
give a try either the svn trunk or the maintenance branch? I'm
attaching the patch just in case.

Regards,

-JJ
Index: lib/matplotlib/legend.py
===
--- lib/matplotlib/legend.py	(revision 6635)
+++ lib/matplotlib/legend.py	(working copy)
@@ -207,6 +207,11 @@
 reps =  int(self.numpoints / len(self._scatteryoffsets)) + 1
 self._scatteryoffsets = np.tile(self._scatteryoffsets, reps)[:self.scatterpoints]
 
+# handles  labels (which can be iterators) need to be
+# explicitly converted to list.
+self._handles_labels = list(handles), list(labels)
+
+
 # _legend_box is an OffsetBox instance that contains all
 # legend items and will be initialized from _init_legend_box()
 # method.
@@ -273,9 +278,9 @@
 
 self._drawFrame = True
 
-# populate the legend_box with legend items.
-self._init_legend_box(handles, labels)
-self._legend_box.set_figure(self.figure)
+# init with null renderer
+#self._init_legend_box(handles, labels, None)
+#self._legend_box.set_figure(self.figure)
 
 
 def _set_artist_props(self, a):
@@ -294,7 +299,7 @@
 ox, oy = self._find_best_position(width, height)
 return ox+xdescent, oy+ydescent
 
-def _findoffset_loc(self, width, height, xdescent, ydescent):
+def _findoffset_loc(self, width, height, xdescent, ydescent, renderer):
 Heper function to locate the legend using the location code
 
 if iterable(self._loc) and len(self._loc)==2:
@@ -304,7 +309,7 @@
 x, y = bbox.x0 + bbox.width * fx, bbox.y0 + bbox.height * fy
 else:
 bbox = Bbox.from_bounds(0, 0, width, height)
-x, y = self._get_anchored_bbox(self._loc, bbox, self.parent.bbox)
+x, y = self._get_anchored_bbox(self._loc, bbox, self.parent.bbox, renderer)
 
 return x+xdescent, y+ydescent
 
@@ -312,6 +317,11 @@
 Draw everything that belongs to the legend
 if not self.get_visible(): return
 
+# populate the legend_box with legend items.
+handles, labels = self._handles_labels
+self._init_legend_box(handles, labels, renderer)
+self._legend_box.set_figure(self.figure)
+
 renderer.open_group('legend')
 
 # find_offset function will be provided to _legend_box and
@@ -320,12 +330,16 @@
 if self._loc == 0:
 self._legend_box.set_offset(self._findoffset_best)
 else:
-self._legend_box.set_offset(self._findoffset_loc)
+def _findoffset_loc(width, height, xdescent, ydescent):
+return self._findoffset_loc(width, height, xdescent, ydescent, renderer)
+self._legend_box.set_offset(_findoffset_loc)
 
+fontsize = renderer.points_to_pixels(self.fontsize)
+
 # if mode == fill, set the width of the legend_box to the
 # width of the paret (minus pads)
 if self._mode in [expand]:
-pad = 2*(self.borderaxespad+self.borderpad)*self.fontsize
+pad = 2*(self.borderaxespad+self.borderpad)*fontsize
 self._legend_box.set_width(self.parent.bbox.width-pad)
 
 if self._drawFrame:
@@ -334,6 +348,8 @@
 self.legendPatch.set_bounds(bbox.x0, bbox.y0,
 bbox.width, bbox.height)
 
+self.legendPatch.set_mutation_scale(fontsize)
+
 if self.shadow:
 shadow = Shadow(self.legendPatch, 2, -2)
 shadow.draw(renderer)
@@ -353,7 +369,7 @@
 return self.fontsize/72.0*self.figure.dpi
 
 
-def _init_legend_box(self, handles, labels):
+def _init_legend_box(self, handles, labels, renderer=None):
 
 Initiallize the legend_box. The legend_box is an instance of
 the OffsetBox, which is packed with legend handles and
@@ -361,6 +377,11 @@
 drawing time.
 
 
+if renderer is None:
+fontsize = self.fontsize
+else:
+fontsize = 

Re: [Matplotlib-users] different PNG and PDF output...

2008-12-16 Thread Jae-Joon Lee
On Tue, Dec 16, 2008 at 12:17 PM, jkitchin jkitc...@andrew.cmu.edu wrote:

 I also observed this with eps output. The png looked fine, but the eps legend
 was very large in my case.

 j


Hmm, it is not clear to me if this is a same issue. I think eps output
is not very sensitive to dpi thing in matplotlib.

I tried a few tests but couldn't see any obvious problems.
If my patch does not fix your problem, please report some more details.

Regards,

-JJ

--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] different PNG and PDF output...

2008-12-16 Thread Jouni K . Seppänen
Jae-Joon Lee lee.j.j...@gmail.com writes:

 So, Lebostein and j, if you know how  to check out using svn, can you
 give a try either the svn trunk or the maintenance branch? I'm
 attaching the patch just in case.

On the svn trunk, the demo examples/api/legend_demo.py now fails at
leg.get_texts() with AttributeError: 'Legend' object has no attribute
'texts'. Calling show() seems to fix the legend so that get_texts
works, so I suspect that the bug is related to the _init_legend_box call
that your patch removes.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] different PNG and PDF output...

2008-12-16 Thread Jae-Joon Lee
On Tue, Dec 16, 2008 at 4:02 PM, Jouni K. Seppänen j...@iki.fi wrote:
 Jae-Joon Lee lee.j.j...@gmail.com writes:

 So, Lebostein and j, if you know how  to check out using svn, can you
 give a try either the svn trunk or the maintenance branch? I'm
 attaching the patch just in case.

 On the svn trunk, the demo examples/api/legend_demo.py now fails at
 leg.get_texts() with AttributeError: 'Legend' object has no attribute
 'texts'. Calling show() seems to fix the legend so that get_texts
 works, so I suspect that the bug is related to the _init_legend_box call
 that your patch removes.

 --
 Jouni K. Seppänen
 http://www.iki.fi/jks


I also see the problem.
And, yes, this is related with _init_legend_box. As the paddings and
such need to be determined at drawing time, I moved this into the
draw() method.
The fix may involve some rearrangement of the code.
I'll work on it.

Thanks,

-JJ




 --
 SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
 The future of the web can't happen without you.  Join us at MIX09 to help
 pave the way to the Next Web now. Learn more and register at
 http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] different PNG and PDF output...

2008-12-16 Thread Jae-Joon Lee
This should now be fixed (maintenance  trunk).

John,
I guess I found what I did wrong last time.
I used emacs svn interface for committing and it seems that some of
the properties are not properly committed.
This time, I simply used the shell command.
let me know if I messed up again.

-JJ

ps. John, are you releasing a new maintenance version? I'm afraid that
my previous patch broke one of the example. Sorry, I thought the fix
was obvious and didn't pay much attention.



On Tue, Dec 16, 2008 at 5:18 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote:
 On Tue, Dec 16, 2008 at 4:02 PM, Jouni K. Seppänen j...@iki.fi wrote:
 Jae-Joon Lee lee.j.j...@gmail.com writes:

 So, Lebostein and j, if you know how  to check out using svn, can you
 give a try either the svn trunk or the maintenance branch? I'm
 attaching the patch just in case.

 On the svn trunk, the demo examples/api/legend_demo.py now fails at
 leg.get_texts() with AttributeError: 'Legend' object has no attribute
 'texts'. Calling show() seems to fix the legend so that get_texts
 works, so I suspect that the bug is related to the _init_legend_box call
 that your patch removes.

 --
 Jouni K. Seppänen
 http://www.iki.fi/jks


 I also see the problem.
 And, yes, this is related with _init_legend_box. As the paddings and
 such need to be determined at drawing time, I moved this into the
 draw() method.
 The fix may involve some rearrangement of the code.
 I'll work on it.

 Thanks,

 -JJ




 --
 SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
 The future of the web can't happen without you.  Join us at MIX09 to help
 pave the way to the Next Web now. Learn more and register at
 http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] different PNG and PDF output...

2008-12-16 Thread John Hunter
On Tue, Dec 16, 2008 at 7:06 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote:

 ps. John, are you releasing a new maintenance version? I'm afraid that
 my previous patch broke one of the example. Sorry, I thought the fix
 was obvious and didn't pay much attention.

Yes, and I had just completed a round of testing when I saw your patch
come in and included it w/o further testing (stupid).  In any case,
there are still a couple of bug fixes and optimizations that are in
progress, and I will continue to push these out as they become
available.  The tarball and OSX binaries will soon be almost fully
automated, and when we stabilize the 98.5 branch, Charlie can post an
update to the win32 binaries.  I plan to cut another bugfix release
tomorrow in any case.

JDH

--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users