-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add consistent legend support across backends #115
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add more context in the linking issue, and why these features are needed. Also add visuals that explicitly show how this new code is adding to the user experience.
Any Thoughts on aliasing in various backend plotting modules, one has to make thing easier for developer too @aloctavodia |
gentle reminder @amaloney |
As a user I would expect the following.
I get this with the first example but I do not get this with the second example. The second plot has a total dimension of 300x800 pixels where a portion of that image is where the plot exists plus the size of the legend. This is not what I would have expected the output to be, since I requested an plot of 300x800 pixels in size. There unfortunately is no easy solution to this. We could instead have an argument where the user can request the legend be outside the plot area. Then in the docstring of the method we indicate that if this argument is selected, the resulting plot area will be smaller in size to accomodate the legend, given the requested figure size. How about you try implementing this idea. |
First of all, there is a slight error; the dimensions should be 800x300, as the height is predefined to be 300 in my test case. Therefore, it is not 300x800 but rather 800x300. If the I have changed the magic number to 500 for the time being and these are the test case def create_example_plot(width):
p = figure(width=width, height=300)
x = np.linspace(0, 10, 100)
grid = gridplot([[p]], merge_tools=False)
p.line(x, np.sin(x), line_color="red")
p.line(x, np.cos(x), line_color="blue")
legend(grid,
[{'color': 'red'}, {'color': 'blue'}],
['sin(x)', 'cos(x)'],
side='auto')
return grid
narrow_plot = create_example_plot(450)
middle_plot = create_example_plot(550)
wide_plot = create_example_plot(800)
show(gridplot([[narrow_plot, middle_plot, wide_plot]])) If seems correct I'll commit right away |
@amaloney Review |
Description
This PR implements consistent legend support across all plotting backends (matplotlib, bokeh, and plotly) and adds automatic legend generation for plot_psense_dist.
Key Changes
plot_psense_dist
(for alpha parameter)Implementation Details
legend()
function for Plotly backendplot_psense_dist
for power scaling factorpc.add_legend("dim_name")
across all backendsChecklist
Issue Targeted
#109
📚 Documentation preview 📚: https://arviz-plots--115.org.readthedocs.build/en/115/