Discussion:
[Matplotlib-users] Annotate not Drawing Properly in a Gridspec - Version 1.4.3
Sean Lake
2015-05-26 17:06:57 UTC
Permalink
Hello all,

I'm using matplotlib 1.4.3 installed using fink with python 2.7.

I'm trying to produce a grid of plots using gridspec that has annotations to label each plot.

Here is the call to annotate the current axes:
ax.annotate( r"$\mathbf{" + lab + ")}$",
xy=(0.5*(xmin+xmax), 0.5*(ymin+ymax)),
xytext=(0.9, 0.9),
textcoords="axes fraction", fontsize=14 )

Where ax is initialized by:
ax = plt.subplot(gs[ coords[0], coords[1] ])

and gs by:
gs = mpgs.GridSpec( 3, 2, wspace=0.0, hspace=0.0 )

The trouble comes in when abs(ymax) < abs(ymin). When that is true, the labels are offset upward by one row, for some reason.

I've attached a script that demonstrates the problem, and an example of the output. I can work around this problem by using "data" coordinates, but even so this reveals a bug somewhere.

Thanks,
Sean Lake
Sean Lake
2015-05-26 19:00:12 UTC
Permalink
Sterling,

Thanks for the pointer. I've already used a workaround where I used "data" coordinates and put it at:
0.9 * (xmax - xmin) + xmin, and similar for y.

I'm really only reporting this so that it can be fixed if there is someone who does need to annotate something in a grid.

Sean
Sean,
Do you need an `annotate`, or just a `text`? `text` has the `transform` keyword, to which you can pass `ax.transAxes`.
ax.text(.9,.9, r"$\mathbf{" + lab + ")}$”,transform=ax.transAxes,ha=‘right’,va=‘center’)
-Sterling
Post by Sean Lake
Hello all,
I'm using matplotlib 1.4.3 installed using fink with python 2.7.
I'm trying to produce a grid of plots using gridspec that has annotations to label each plot.
ax.annotate( r"$\mathbf{" + lab + ")}$",
xy=(0.5*(xmin+xmax), 0.5*(ymin+ymax)),
xytext=(0.9, 0.9),
textcoords="axes fraction", fontsize=14 )
ax = plt.subplot(gs[ coords[0], coords[1] ])
gs = mpgs.GridSpec( 3, 2, wspace=0.0, hspace=0.0 )
The trouble comes in when abs(ymax) < abs(ymin). When that is true, the labels are offset upward by one row, for some reason.
I've attached a script that demonstrates the problem, and an example of the output. I can work around this problem by using "data" coordinates, but even so this reveals a bug somewhere.
Thanks,
Sean Lake
<BugDemo.py><BugDemo.pdf>------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Benjamin Root
2015-05-26 19:10:08 UTC
Permalink
I think this is a feature/bug that got reverted in the master branch.
Perhaps you could try building matplotlib from source and seeing if the
problem goes away?

Cheers!
Ben Root
Post by Sean Lake
Sterling,
Thanks for the pointer. I've already used a workaround where I used "data"
0.9 * (xmax - xmin) + xmin, and similar for y.
I'm really only reporting this so that it can be fixed if there is someone
who does need to annotate something in a grid.
Sean
Sean,
Do you need an `annotate`, or just a `text`? `text` has the `transform`
keyword, to which you can pass `ax.transAxes`.
ax.text(.9,.9, r"$\mathbf{" + lab +
")}$”,transform=ax.transAxes,ha=‘right’,va=‘center’)
-Sterling
Post by Sean Lake
Hello all,
I'm using matplotlib 1.4.3 installed using fink with python 2.7.
I'm trying to produce a grid of plots using gridspec that has
annotations to label each plot.
Post by Sean Lake
ax.annotate( r"$\mathbf{" + lab + ")}$",
xy=(0.5*(xmin+xmax), 0.5*(ymin+ymax)),
xytext=(0.9, 0.9),
textcoords="axes fraction", fontsize=14 )
ax = plt.subplot(gs[ coords[0], coords[1] ])
gs = mpgs.GridSpec( 3, 2, wspace=0.0, hspace=0.0 )
The trouble comes in when abs(ymax) < abs(ymin). When that is true, the
labels are offset upward by one row, for some reason.
Post by Sean Lake
I've attached a script that demonstrates the problem, and an example of
the output. I can work around this problem by using "data" coordinates, but
even so this reveals a bug somewhere.
Post by Sean Lake
Thanks,
Sean Lake
<BugDemo.py><BugDemo.pdf>------------------------------------------------------------------------------
Post by Sean Lake
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________
Post by Sean Lake
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Eric Firing
2015-05-26 19:55:11 UTC
Permalink
Post by Benjamin Root
I think this is a feature/bug that got reverted in the master branch.
Perhaps you could try building matplotlib from source and seeing if the
problem goes away?
Ben, it looks familiar, and related to a bizarre feature that I thought
we had eliminated--but I just tried it with master, and it's still
there. Maybe the change is still languishing in an open PR.

Sean,

I think you are understandably misunderstanding the confusing annotation
API.

ax.annotate( r"$\mathbf{" + label + ")}$",
xy=(0.9, 0.9),
xycoords="axes fraction",
fontsize=14 )

If you change your annotation call to the simpler version above, I think
it will do what you intended.

Eric
Post by Benjamin Root
Cheers!
Ben Root
Sterling,
Thanks for the pointer. I've already used a workaround where I used
0.9 * (xmax - xmin) + xmin, and similar for y.
I'm really only reporting this so that it can be fixed if there is
someone who does need to annotate something in a grid.
Sean
Sean,
Do you need an `annotate`, or just a `text`? `text` has the
`transform` keyword, to which you can pass `ax.transAxes`.
ax.text(.9,.9, r"$\mathbf{" + lab +
")}$”,transform=ax.transAxes,ha=‘right’,va=‘center’)
-Sterling
Post by Sean Lake
Hello all,
I'm using matplotlib 1.4.3 installed using fink with python 2.7.
I'm trying to produce a grid of plots using gridspec that has
annotations to label each plot.
Post by Sean Lake
ax.annotate( r"$\mathbf{" + lab + ")}$",
xy=(0.5*(xmin+xmax), 0.5*(ymin+ymax)),
xytext=(0.9, 0.9),
textcoords="axes fraction", fontsize=14 )
ax = plt.subplot(gs[ coords[0], coords[1] ])
gs = mpgs.GridSpec( 3, 2, wspace=0.0, hspace=0.0 )
The trouble comes in when abs(ymax) < abs(ymin). When that is
true, the labels are offset upward by one row, for some reason.
Post by Sean Lake
I've attached a script that demonstrates the problem, and an
example of the output. I can work around this problem by using
"data" coordinates, but even so this reveals a bug somewhere.
Post by Sean Lake
Thanks,
Sean Lake
<BugDemo.py><BugDemo.pdf>------------------------------------------------------------------------------
Post by Sean Lake
One dashboard for servers and applications across
Physical-Virtual-Cloud
Post by Sean Lake
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable
Insights
Post by Sean Lake
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________
Post by Sean Lake
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Loading...