Re: [matplotlib-devel] Patch - Tick marks and grid lines are not aligned when using vectorial backends

2007-02-28 Thread John Hunter
On 2/28/07, Nicolas Grilly <[EMAIL PROTECTED]> wrote:

> Have you seen this patch I proposed several days ago, during your
> vacations? Can you reproduce the problem on your machine and do you
> agree with the solution?

No, I missed it the first time around, thanks for resending.  I've
been battling these half-center alignment problems since we added the
agg backend -- search throughout the _backend_agg.cpp backend for
"snapto".I do two things differently from you, and we need to
decide on the right approach and do it consistently.

+  ppath->vertex(i, &x, &y);
+  x = x - 0.5;
+  y = y + 0.5;
+  ppath->modify_vertex(i, x, y);

You are subtracting from x and adding to y, and preserving the
original float, whereas I have been truncating to int and adding 0.5
to insure that the number is a pixel center.  Eg,

  //snapto pixel centers
  l = (int)l + 0.5;
  b = (int)b + 0.5;
  r = (int)r + 0.5;
  t = (int)t + 0.5;

What is the justification for subtracting from x and adding to y?  And
do you agree that it is preferable to first truncate to an int before
doing the 0.5 offset to insure the pixel center?

I do agree that it makes more sense to do this in the backend since
the notion of pixel center has no place in the vector backends.  Would
you consider looking over the rest of backend agg and making sure this
is applied consistently and correctly?  In the past, I have been only
applying this adjustment on horizontal and vertical lines, but perhaps
we should apply it to all vertices in the agg backend regardless, as
you are doing in your patch.  I would love to vanquish this pesky
problem once and for all -- it seems that everytime I push it down in
one place, it crops up in another.

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-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] strange alpha legend bug

2007-02-28 Thread John Hunter
a doughnut to the developer who can figure this one out for me!

If you resize the figure window slightly, the alpha channel gets
whacked on the rectangles.  This only happens if the legend is added
to the axes -- comment that out and the alpha channel is fine.  I
suspect we are screwing up somewhere in the way we copy properties
from legended objects to their legend proxies (ie we are reversing
this somewhere and copying properties from a proxy to the axes

The problem is in svn and probably earlier releases but I haven't tested.

from pylab import figure, show, cm, nx
from matplotlib.patches import Rectangle
fig = figure()
ax = fig.add_subplot(111, axisbelow=True)
ax.grid(True)

ax.plot([1,2,3,4,5,6,7])

ax.axvspan(1,2, facecolor='red', alpha=0.5)
ax.axvspan(3,4, facecolor='green', alpha=0.5)

red = Rectangle((0,0), 1, 1, facecolor='red', alpha=0.5)
green = Rectangle((0,0), 1, 1, facecolor='green', alpha=0.5)

# comment out next line and bug goes away!
ax.legend((red, green), ('red', 'green'), loc='best')

show()

-
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-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] strange alpha legend bug

2007-02-28 Thread Jouni K . Seppänen
"John Hunter" <[EMAIL PROTECTED]> writes:

> I suspect we are screwing up somewhere in the way we copy properties
> from legended objects to their legend proxies (ie we are reversing
> this somewhere and copying properties from a proxy to the axes

Here's at least a clue: change your alphas from 0.5 to 0.1. Then
resize the window several times and watch the rectangles become 
a little bit darker each time. I suspect that extra copies of the
rectangles are being created.

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


-
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-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel