Annotate not Drawing Properly in a Gridspec - Version 1.4.3

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

BugDemo.py (1.17 KB)

BugDemo.pdf (93 KB)

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

···

On May 26, 2015, at 10:06AM, Sean Lake <odysseus9672@...287...> wrote:

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

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

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

···

On May 26, 2015, at 11:54, Sterling Smith <smithsp@...3304...> wrote:

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

On May 26, 2015, at 10:06AM, Sean Lake <odysseus9672@...287...> wrote:

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

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

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

···

On Tue, May 26, 2015 at 3:00 PM, Sean Lake <odysseus9672@…287…> wrote:

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

On May 26, 2015, at 11:54, Sterling Smith <smithsp@…3304…> wrote:

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

On May 26, 2015, at 10:06AM, Sean Lake <odysseus9672@…287…> wrote:

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

<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

Matplotlib-users@lists.sourceforge.net

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



Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

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

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

···

On 2015/05/26 9:10 AM, Benjamin Root wrote:

Cheers!
Ben Root

On Tue, May 26, 2015 at 3:00 PM, Sean Lake <odysseus9672@…287… > <mailto:odysseus9672@…287…>> wrote:

    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

     > On May 26, 2015, at 11:54, Sterling Smith <smithsp@…3304… > <mailto:smithsp@…3304…>> wrote:
     >
     > 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
     >
     > On May 26, 2015, at 10:06AM, Sean Lake <odysseus9672@…287… > <mailto:odysseus9672@…287…>> wrote:
     >
     >> 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
     >>
    <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
     >> Matplotlib-users@lists.sourceforge.net
    <mailto:Matplotlib-users@lists.sourceforge.net>
     >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
     >

    ------------------------------------------------------------------------------
    _______________________________________________
    Matplotlib-users mailing list
    Matplotlib-users@lists.sourceforge.net
    <mailto:Matplotlib-users@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------

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