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

Plotly 3.8 support #3644

Merged
merged 2 commits into from Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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