You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For many years we have failed at providing an simple way for users to add legends that:
were located outside the center plot area
could work with renderer legend kwargs, e.g. legend_group
While answering this question on DPO and refreshing my memory about the code in the plotting API, I had an epiphany. If you just do this bit first, before adding any renderers with legend kwargs:
p.add_layout(Legend(location="center"), "right")
then due to how renderer legend kwargs work, any subsequent renderer calls:
will use that existing legend that is outside the plot frame.
On the one hand, 🤯 wow that's an easy solution to a very old commonly asked for thing that has stubbornly remained not-simple. On the other hand... it is definitely a bit fragile. If you add the renderer first, then a legend will be auto-created (inside the plot), since there is not already one that can be used. You'd just end up with an empty legend outside the plot, I think.
So, my question is: do we lean into this and document it as a good/official way to achieve this task? This has been asked for for years, and here is a a solution right in front of us. But we would need to strongly emphasize that the order matters critically.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For many years we have failed at providing an simple way for users to add legends that:
legend_group
While answering this question on DPO and refreshing my memory about the code in the plotting API, I had an epiphany. If you just do this bit first, before adding any renderers with legend kwargs:
then due to how renderer legend kwargs work, any subsequent renderer calls:
will use that existing legend that is outside the plot frame.
On the one hand, 🤯 wow that's an easy solution to a very old commonly asked for thing that has stubbornly remained not-simple. On the other hand... it is definitely a bit fragile. If you add the renderer first, then a legend will be auto-created (inside the plot), since there is not already one that can be used. You'd just end up with an empty legend outside the plot, I think.
So, my question is: do we lean into this and document it as a good/official way to achieve this task? This has been asked for for years, and here is a a solution right in front of us. But we would need to strongly emphasize that the order matters critically.
cc @bokeh/dev
Beta Was this translation helpful? Give feedback.
All reactions