# 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,


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


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

···

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,

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

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

Sterling,

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

y = self._bandstructure.fermiLevel()
self._axes.axhline(y=y, linestyle=':')

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:

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

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,

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

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

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