Label for axhline

Hi,

  I would like to add a label or tick label for an axhline(), in such

a way that the labels follows the location of the hline.

  The x-coordinate of the label should be in screen coordinates (a

little to the right of the plot) - but the y-coordinate should be
in data coordinates.

  Any good suggestions?

  Best regards,

  Mads
···
-- +-----------------------------------------------------+
| Mads Ipsen |
+----------------------+------------------------------+
| Gåsebæksvej 7, 4. tv | |
| DK-2500 Valby | phone: +45-29716388 |
| Denmark | email: |
+----------------------+------------------------------+

mads.ipsen@…287…

Mads,

I recommend trying a text object[1], with a transform which is a blended transform from a transform factory[2]. Also, you probably want the x coordinate in axes coordinates, with a left horizontal alignment.

-Sterling

[1] http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.text
[2] http://matplotlib.org/users/transforms_tutorial.html#blended-transformations

···

On Nov 28, 2012, at 4:27AM, Mads Ipsen wrote:

Hi,

I would like to add a label or tick label for an axhline(), in such a way that the labels follows the location of the hline.

The x-coordinate of the label should be in screen coordinates (a little to the right of the plot) - but the y-coordinate should be in data coordinates.

Any good suggestions?

Best regards,

Mads

--
+-----------------------------------------------------+
> Mads Ipsen |
+----------------------+------------------------------+
> Gåsebæksvej 7, 4. tv | |
> DK-2500 Valby | phone: +45-29716388 |
> Denmark | email:
mads.ipsen@...287...
>
+----------------------+------------------------------+

------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
INSIGHTS What's next for parallel hardware, programming and related areas?
Interviews and blogs by thought leaders keep you ahead of the curve.
http://goparallel.sourceforge.net_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Sterling,

Thanks - I ended up adding an extra y-tick with minor=True. Something along these lines:

# Add Fermi line
y = self._bandstructure.fermiLevel()
self._axes.axhline(y=y, linestyle=':')

# Add Fermi tick
tick = self._axes.set_yticks([y], minor=True)[0]
tick.label1On = False
tick.label2On = True
self._axes.set_yticklabels([r'\\epsilon\_\\mathrm\{F\}'], minor=True,
                             fontsize=font_size*1.19, verticalalignment='center')

Evil?

···

On 28/11/2012 17:35, Sterling Smith wrote:

Mads,

I recommend trying a text object[1], with a transform which is a blended transform from a transform factory[2]. Also, you probably want the x coordinate in axes coordinates, with a left horizontal alignment.

-Sterling

[1] http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.text
[2] http://matplotlib.org/users/transforms_tutorial.html#blended-transformations

On Nov 28, 2012, at 4:27AM, Mads Ipsen wrote:

Hi,

I would like to add a label or tick label for an axhline(), in such a way that the labels follows the location of the hline.

The x-coordinate of the label should be in screen coordinates (a little to the right of the plot) - but the y-coordinate should be in data coordinates.

Any good suggestions?

Best regards,

Mads
  
--
+-----------------------------------------------------+
> Mads Ipsen |
+----------------------+------------------------------+
> G�seb�ksvej 7, 4. tv | |
> DK-2500 Valby | phone: +45-29716388 |
> Denmark | email:
mads.ipsen@...287...
  >
+----------------------+------------------------------+

------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
INSIGHTS What's next for parallel hardware, programming and related areas?
Interviews and blogs by thought leaders keep you ahead of the curve.
http://goparallel.sourceforge.net_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
+-----------------------------------------------------+

Mads Ipsen |

+----------------------+------------------------------+

G�seb�ksvej 7, 4. tv | |
DK-2500 Valby | phone: +45-29716388 |
Denmark | email: mads.ipsen@...287... |

+----------------------+------------------------------+