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
Enable single legend for NdLayout
(instead of multiple identical legends in each subplot)
#332
Comments
Thanks for the nice example! I've occasionally wondered if Unless you can argue that information held by a legend contains meaningful information? Maybe if the legend held the association between a descriptive label (about the data) and keys (also about a data) in a way that doesn't refer to what the elements look like? Just a thought. |
I would definitely agree that there is valuable information contained in a legend that is independent of the visualisation (as this example shows). I like the idea of having a However, it feels like such a |
Is there currently any workaround for adding such a single legend manually to the matplotlib figure created by Holoviews? I don't mind if the solution is kludgy, but it would be a pity if I had to reproduce the figure from scratch entirely in matplotlib without being able to leverage Holoviews to get me most of the way. (Although it probably wouldn't be a huge effort so it's not a showstopper if it isn't currently possible.) |
I played with the idea of dynamically generated Legend and Colorbar elements, which could potentially make some of the plotting code cleaner in that regard but that's more of an implementation detail anyway because the user shouldn't really handle these directly anyway. There are a few workarounds to get this to work already, but it should definitely be more convenient. Here's what I came up with, I ended up using GridSpace again because it's more convenient for this kind of parameter exploration but it should work with NdLayout as well: legend_opts = {'NdOverlay': dict(show_legend=True, legend_position='right')}
grid[phases[-1], 10] = grid[phases[-1], 10](plot=legend_opts)
grid You asked about the difference between GridSpace and NdLayout before and it's basically that GridSpace only supports two key dimensions and these two dimensions map directly onto the x- and y-axis of the grid, in terms of plotting it also automatically handles shared axes. |
I just pushed a commit (4ac3c4b) that fixes the show_legend plot option on GridSpaces, you should now get something similar to the above when you enable it. For NdLayouts you would still have to manually enable the legend on the plot where you want it again highlighting the difference between the two. To summarize:
|
The code snippet below creates an
NdLayout
object with multiple sub-panels, each of which is displayed with its own legend (see screenshot). However, all these legends are identical. It would be great to be able to attach a single legend to the top-levelNdLayout
instead of multiple ones to the individual sub-plots. This probably also applies toGridSpace
, although I can't get legends to work withGridSpace
at the moment so don't know how it handles them.I wonder whether it would make sense to also allow "sharing" of other properties (such as axis labels/ticks, etc.) between sub-plots. However, I'm not sure whether this is covered by the existence of
GridSpace
because I don't fully understand the relation and difference betweenNdLayout
andGridSpace
.The text was updated successfully, but these errors were encountered: