Placing Label in a specific position of axis relative to the axis screen size

  1. I have a simple scatter plot.
  2. The plot is dynamic - i.e. data that are plotted change depending on selection in a widget.
  3. Its size is not fixed (using stretch_both in the layout).

I would like to place a Label in the plot that would display the correlation coefficient of the data currently displayed. The Label should change every time different data is selected.

The issue I have is, that since I do not know the size of the plot in screen coordinates beforehand (see point 3) I cannot place the label in a location I want (i.e. somewhere roughly in the upper right corner), using screen coordinates. Also, since the plot is dynamic, I cannot use data coordinates to place the Label.

Is there any way to resolve this ?

Label accepts screen units, as shown in the docs. Are you saying you tried that and could not get the result you wanted? Please provide a complete Minimal Reproducible Example of what you have attempted.

Hello Bryan, I am afraid I don’t know how to make a MRE, as I don’t know how to do what I want to do - it is not a bug. I will try to explain again.

I want to place label in the upper right corner of a plot (axis) - say 10% off the right and top border. Since the plot size is not set to fixed but rather the sizing_mode is set “stretch_both”, I don’t know the size of the plot (in pixels) at the time of its creation. So I do not know to what to set the x and y screen coordinates in the Label.

The example code at the link I provided explicitly demonstrates setting x_units to "screen".