Add consistent legend support across backends#115
Add consistent legend support across backends#115aloctavodia merged 3 commits intoarviz-devs:mainfrom
Conversation
amaloney
left a comment
There was a problem hiding this comment.
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 |
7c173a4 to
09ca520
Compare
OriolAbril
left a comment
There was a problem hiding this comment.
This is a great starting point, thanks!
I have rebased it and taken care of tests and docs so it can be merged, sorry we haven't been able to do proper continued reviews at a reasonable pace so far.
No worries sénior 👍 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #115 +/- ##
==========================================
+ Coverage 72.44% 73.06% +0.61%
==========================================
Files 42 43 +1
Lines 4921 4941 +20
==========================================
+ Hits 3565 3610 +45
+ Misses 1356 1331 -25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|








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_distfor power scaling factorpc.add_legend("dim_name")across all backendsChecklist
Issue Targeted
#109
📚 Documentation preview 📚: https://arviz-plots--115.org.readthedocs.build/en/115/