[Matplotlib-users] 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.ip...@gmail.com | +--+--+ -- 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
Re: [Matplotlib-users] Label for axhline
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.ip...@gmail.com | +--+--+ -- 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 -- 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
Re: [Matplotlib-users] Label for axhline
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.ip...@gmail.com | +--+--+ -- 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 -- +-+ | Mads Ipsen | +--+--+ | Gåsebæksvej 7, 4. tv | | | DK-2500 Valby| phone: +45-29716388 | | Denmark | email: mads.ip...@gmail.com | +--+--+ -- 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