1

I currently annotate my charts with the last value of each series by adding a Label and supplying my the name of corresponding range it's plotted on:

Label(
    ...
    x=data.index.max(),
    y=data.loc[data.index.max(), 'my_col'],
    y_range_name='my_range'
    ...
)

Which gives me:

section of line chart on multiple axes, with text annotations of each series' last value

How do I move the labels so they are positioned on their respective axis? Example:

enter image description here

Please note that my labels' y-positioning is off, so I need some help with that aspect too. I've tried tweaking the y_offset but this has not yielded any consistently good results. My data are always numerical time series.

Griffin
  • 13,184
  • 4
  • 29
  • 43

1 Answers1

0

As of Bokeh 1.2 there is no built-in annotation or glyph that will display outside the central plot area. There is an open issue on GitHub that this is similar to that you can follow or comment on. For the time being, something like this would require making a custom extension

bigreddot
  • 33,642
  • 5
  • 69
  • 122
  • Where in that GitHub issue discussion does it state the inability to have an annotation outside of the plot area? – Griffin Jul 01 '19 at 15:03
  • It doesn't explicitly, but I regard it as related to that, because a precursor to having tooltips that "stick" is having an API for programmatically placing tooltips. Placing them outside the axes would be a small (reasonable) leap from there, but you are correct it is not explicitly stated. Your comments, input there would be helpful. – bigreddot Jul 01 '19 at 15:29
  • I don't want a tool tip, just the Label. So all in SVG space. Guess I will have to stick with what I have. Thanks. Any idea why the y-position is off? – Griffin Jul 02 '19 at 09:55
  • Never mind, it was user error on the y position stuff. I wasn't being specific enough when filtering nans. – Griffin Jul 02 '19 at 12:19
  • OK FWIW the image you have of the thing over the axis is what I consider (and would be implemented wit) hover tooltips. Glad you have it sorted out, regardless! – bigreddot Jul 02 '19 at 17:26
  • I've just [seen this](https://stackoverflow.com/a/46731430/745808) which I've used to place labels over the axis like i wanted. However, the resulting "view box" sometimes isn't wide enough and the labels get clipped. Is there a way to auto size this view so the labels are always visible? – Griffin Oct 23 '19 at 12:52
  • Actually, using `x_units='screen'` is also giving inconsistent results. Do you have any tips? I feel like I'm so close. – Griffin Oct 23 '19 at 13:10
  • SO is not a good place for iterative discussion in general, and in the comments is even worse. I also definitely don't have suggestions without a minimal example of code you are starting from that can be tried out and experimented with. I'd suggest moving this to the project Discourse https://discourse.bokeh.org – bigreddot Oct 23 '19 at 18:35
  • Hi @bigreddot, I'm trying to accomplish the same thing, two years have been past, is there any updates ? if not, could you give me some hint how to use custom extension to display LabelSet on axis ticks out side the plot box? – TMS Nov 04 '21 at 13:08