Skip to content
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

Create single legend outside plots rather than duplicate legends inside #1794

Open
claresloggett opened this issue Aug 7, 2017 · 5 comments
Labels
type: feature A major new feature

Comments

@claresloggett
Copy link

When creating a plot with .overlay().layout(), I get a legend inside the plotting area of each plot. Since the variables are the same across the layout, all the legends are identical. I'd like to be able to get a single legend outside the plots, rather than multiple legends all inside the plots.

Even when not using .layout(), I'd like to be able to move the .overlay() legend outside the plotting area as in some cases the legend is large.

This is using the bokeh backend, where I believe it's currently not possible to get a legend outside the plots. I'm not sure if the situation is any different with the matplotlib backend.

@jlstevens jlstevens added the type: feature A major new feature label Aug 7, 2017
@philippjfr
Copy link
Member

Thanks for filing this, I've been meaning to address this at some point so it's good to have an issue for it.

This is using the bokeh backend, where I believe it's currently not possible to get a legend outside the plots

That's not accurate legend_position='right'/'left'/'top'/'bottom' allows placing the legend outside the plot area, the same options also work in matplotlib.

@RichardJamesLopez
Copy link

I have a couple of questions about the NdOverlay.

  1. Is there a limit to how many items the legend will show? I have a file with 30 values within the legend and haven't been able to have the legend appear. (I have included a version below that has 15 different 'Tm' values and it works. However, once I try and running this with a file that has 30 values for 'Tm' no legend seems to appear) (One hypothesis I had was that maybe it has to do with amount of value_dimensions)

  2. Is there a way to set the default to not have all values selected? Is their a way to have none selected as a default or I program which want to start with.

I am running this in Jupyter using Python 3.

import csv 
import numpy as np 
import pandas as pd 
import holoviews as hv 
hv.extension('bokeh') 

macro_df = pd.read_csv('filename_with_15_different_Tm.csv', header=0)

key_dimensions   = [('Posnum', 'Posnum'), ('Tm', 'Tm')]
value_dimensions = [('Player','Player'),('Pos','Pos'),('Posnum','Posnum'),('Age','Age'),('Tm','Tm'),('G','G'),('MP','MP'),('PER','PER'),('TS%','TS%'),('3PAr','3PAr'),('FTr','FTr'),('ORB%','ORB%'),('DRB%','DRB%'),('TRB%','TRB%'),('AST%','AST%'),('STL%','STL%'),('BLK%','BLK%'),('TOV%','TOV%'),('USG%','USG%'),('OWS','OWS'),('DWS','DWS'),('WS','WS'), ('WS/48','WS/48'), ('OBPM','OBPM'),('DBPM','DBPM'),('BPM','BPM'),('VORP','VORP')
]
macro = hv.Table(macro_df, kdims=key_dimensions, vdims=value_dimensions)

%%opts Scatter [width=900 height=600 scaling_method='width' scaling_factor=5 size_index=1 show_grid=True] 
%%opts Scatter (color=Cycle('Category20') line_color='k')
%%opts NdOverlay [legend_position='bottom' show_frame=False legend_cols=5]
gdp_unem_scatter = macro.to.scatter('Posnum', ['VORP', 'MP'])
gdp_unem_scatter.overlay('Tm')

image

@wmayner
Copy link

wmayner commented Mar 28, 2019

@philippjfr, is it possible to use Bokeh's legend_position functionality in a Holoviews plot?

@DancingQuanta
Copy link
Contributor

I am interested in creating layout with a shared legend! I think the bokeh layout refactor may have made that easier?

@NumesSanguis
Copy link

Just curious if there is any update on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A major new feature
Projects
None yet
Development

No branches or pull requests

7 participants