Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge 4557972 into a20c4de
  • Loading branch information
jonmmease committed Apr 22, 2019
2 parents a20c4de + 4557972 commit fed19fe
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
8 changes: 6 additions & 2 deletions holoviews/plotting/plotly/element.py
Expand Up @@ -10,7 +10,8 @@
from ..plot import GenericElementPlot, GenericOverlayPlot
from ..util import dim_range_key, dynamic_update
from .plot import PlotlyPlot
from .util import STYLE_ALIASES, get_colorscale, merge_figure
from .util import (
STYLE_ALIASES, get_colorscale, merge_figure, legend_trace_types)


class ElementPlot(PlotlyPlot, GenericElementPlot):
Expand Down Expand Up @@ -158,9 +159,12 @@ def graph_options(self, element, ranges, style):
legend = element.label

opts = dict(
showlegend=self.show_legend, legendgroup=element.group,
name=legend, **self.trace_kwargs)

if self.trace_kwargs.get('type', None) in legend_trace_types:
opts.update(
showlegend=self.show_legend, legendgroup=element.group)

if self._style_key is not None:
styles = self._apply_transforms(element, ranges, style)
opts[self._style_key] = {STYLE_ALIASES.get(k, k): v
Expand Down
3 changes: 2 additions & 1 deletion holoviews/plotting/plotly/renderer.py
Expand Up @@ -5,7 +5,8 @@

import param
with param.logging_level('CRITICAL'):
from plotly.offline.offline import utils, get_plotlyjs, init_notebook_mode
from plotly import utils
from plotly.offline import get_plotlyjs, init_notebook_mode
import plotly.graph_objs as go

from ..renderer import Renderer, MIME_TYPES, HTML_TAGS
Expand Down
28 changes: 28 additions & 0 deletions holoviews/plotting/plotly/util.py
Expand Up @@ -79,6 +79,34 @@
'scattermapbox': ['mapbox']
}

# trace types that support legends
legend_trace_types = {
'scatter',
'bar',
'box',
'histogram',
'histogram2dcontour',
'contour',
'scatterternary',
'violin',
'waterfall',
'pie',
'scatter3d',
'scattergeo',
'scattergl',
'splom',
'pointcloud',
'scattermapbox',
'scattercarpet',
'contourcarpet',
'ohlc',
'candlestick',
'scatterpolar',
'scatterpolargl',
'barpolar',
'area',
}

# Aliases - map common style options to more common names

STYLE_ALIASES = {'line_width': 'width', 'alpha': 'opacity',
Expand Down

0 comments on commit fed19fe

Please sign in to comment.