Skip to content

Commit

Permalink
Merge 770777b into 82acc56
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Sep 7, 2019
2 parents 82acc56 + 770777b commit f24eef8
Show file tree
Hide file tree
Showing 25 changed files with 133 additions and 20 deletions.
2 changes: 1 addition & 1 deletion holoviews/plotting/plotly/annotation.py
Expand Up @@ -13,7 +13,7 @@ class LabelPlot(ScatterPlot):
yoffset = param.Number(default=None, doc="""
Amount of offset to apply to labels along x-axis.""")

style_opts = ['color', 'family', 'size']
style_opts = ['visible', 'color', 'family', 'size']

_nonvectorized_styles = []

Expand Down
25 changes: 17 additions & 8 deletions holoviews/plotting/plotly/chart.py
Expand Up @@ -28,10 +28,17 @@ class ScatterPlot(ChartPlot, ColorbarPlot):
Index of the dimension from which the color will the drawn""")

style_opts = [
'marker', 'color', 'cmap', 'alpha', 'size', 'sizemin', 'selectedpoints'
'visible',
'marker',
'color',
'cmap',
'alpha',
'size',
'sizemin',
'selectedpoints',
]

_nonvectorized_styles = ['cmap', 'alpha', 'sizemin', 'selectedpoints']
_nonvectorized_styles = ['visible', 'cmap', 'alpha', 'sizemin', 'selectedpoints']

trace_kwargs = {'type': 'scatter', 'mode': 'markers'}

Expand Down Expand Up @@ -62,7 +69,7 @@ class CurvePlot(ChartPlot, ColorbarPlot):

trace_kwargs = {'type': 'scatter', 'mode': 'lines'}

style_opts = ['color', 'dash', 'line_width']
style_opts = ['visible', 'color', 'dash', 'line_width']

_nonvectorized_styles = style_opts

Expand All @@ -76,7 +83,7 @@ def get_data(self, element, ranges, style):

class AreaPlot(ChartPlot):

style_opts = ['color', 'dash', 'line_width']
style_opts = ['visible', 'color', 'dash', 'line_width']

trace_kwargs = {'type': 'scatter', 'mode': 'lines'}

Expand Down Expand Up @@ -112,7 +119,7 @@ def get_data(self, element, ranges, style):

class SpreadPlot(ChartPlot):

style_opts = ['color', 'dash', 'line_width']
style_opts = ['visible', 'color', 'dash', 'line_width']

trace_kwargs = {'type': 'scatter', 'mode': 'lines'}

Expand All @@ -129,13 +136,13 @@ def get_data(self, element, ranges, style):
upper = mean + pos_error
return [{x: xs, y: lower, 'fill': None},
{x: xs, y: upper, 'fill': 'tonext'+y}]


class ErrorBarsPlot(ChartPlot, ColorbarPlot):

trace_kwargs = {'type': 'scatter', 'mode': 'lines', 'line': {'width': 0}}

style_opts = ['color', 'dash', 'line_width', 'thickness']
style_opts = ['visible', 'color', 'dash', 'line_width', 'thickness']

_nonvectorized_styles = style_opts

Expand Down Expand Up @@ -176,6 +183,8 @@ class BarPlot(ElementPlot):

stacked = param.Boolean(default=False)

style_opts = ['visible']

trace_kwargs = {'type': 'bar'}

def get_extents(self, element, ranges, range_type='combined'):
Expand Down Expand Up @@ -287,7 +296,7 @@ class HistogramPlot(ElementPlot):

trace_kwargs = {'type': 'bar'}

style_opts = ['color', 'line_color', 'line_width', 'opacity']
style_opts = ['visible', 'color', 'line_color', 'line_width', 'opacity']

_style_key = 'marker'

Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/plotly/chart3d.py
Expand Up @@ -41,7 +41,7 @@ class SurfacePlot(Chart3DPlot, ColorbarPlot):

trace_kwargs = {'type': 'surface'}

style_opts = ['alpha', 'lighting', 'lightposition', 'cmap']
style_opts = ['visible', 'alpha', 'lighting', 'lightposition', 'cmap']

def graph_options(self, element, ranges, style):
opts = super(SurfacePlot, self).graph_options(element, ranges, style)
Expand Down
8 changes: 5 additions & 3 deletions holoviews/plotting/plotly/element.py
Expand Up @@ -213,9 +213,11 @@ def graph_options(self, element, ranges, style):
opts[self._style_key] = {STYLE_ALIASES.get(k, k): v
for k, v in styles.items()}

# Move selectedpoints from style key back to root
if 'selectedpoints' in opts.get(self._style_key, {}):
opts['selectedpoints'] = opts[self._style_key].pop('selectedpoints')
# Move certain options from the style key back to root
for k in ['selectedpoints', 'visible']:
if k in opts.get(self._style_key, {}):
opts[k] = opts[self._style_key].pop(k)

else:
opts.update({STYLE_ALIASES.get(k, k): v
for k, v in style.items() if k != 'cmap'})
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/plotly/raster.py
Expand Up @@ -9,7 +9,7 @@

class RasterPlot(ColorbarPlot):

style_opts = ['cmap', 'alpha']
style_opts = ['visible', 'cmap', 'alpha']

trace_kwargs = {'type': 'heatmap'}

Expand Down
8 changes: 4 additions & 4 deletions holoviews/plotting/plotly/stats.py
Expand Up @@ -14,7 +14,7 @@ class BivariatePlot(ChartPlot, ColorbarPlot):

trace_kwargs = {'type': 'histogram2dcontour'}

style_opts = ['cmap', 'showlabels', 'labelfont', 'labelformat', 'showlines']
style_opts = ['visible', 'cmap', 'showlabels', 'labelfont', 'labelformat', 'showlines']

_style_key = 'contours'

Expand Down Expand Up @@ -58,7 +58,7 @@ class DistributionPlot(ElementPlot):
filled = param.Boolean(default=True, doc="""
Whether the bivariate contours should be filled.""")

style_opts = ['color', 'dash', 'line_width']
style_opts = ['visible', 'color', 'dash', 'line_width']

trace_kwargs = {'type': 'scatter', 'mode': 'lines'}

Expand Down Expand Up @@ -112,7 +112,7 @@ class BoxWhiskerPlot(MultiDistributionPlot):
is drawn as a dashed line inside the box(es). If "sd" the
standard deviation is also drawn.""")

style_opts = ['color', 'alpha', 'outliercolor', 'marker', 'size']
style_opts = ['visible', 'color', 'alpha', 'outliercolor', 'marker', 'size']

trace_kwargs = {'type': 'box'}

Expand All @@ -136,7 +136,7 @@ class ViolinPlot(MultiDistributionPlot):
is drawn as a dashed line inside the box(es). If "sd" the
standard deviation is also drawn.""")

style_opts = ['color', 'alpha', 'outliercolor', 'marker', 'size']
style_opts = ['visible', 'color', 'alpha', 'outliercolor', 'marker', 'size']

trace_kwargs = {'type': 'violin'}

Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/plotly/tabular.py
Expand Up @@ -13,7 +13,7 @@ class TablePlot(ElementPlot):

trace_kwargs = {'type': 'table'}

style_opts = ['line', 'fill', 'align', 'font', 'cell_height']
style_opts = ['visible', 'line', 'fill', 'align', 'font', 'cell_height']

_style_key = 'cells'

Expand Down
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testareaplot.py
Expand Up @@ -50,3 +50,8 @@ def test_area_fill_between_xs(self):
self.assertEqual(state['data'][1]['fill'], 'tonextx')
self.assertEqual(state['layout']['xaxis']['range'], [0.5, 3])
self.assertEqual(state['layout']['yaxis']['range'], [0, 2])

def test_area_visible(self):
curve = Area([1, 2, 3]).options(visible=False)
state = self._get_plot_state(curve)
self.assertEqual(state['data'][0]['visible'], False)
7 changes: 6 additions & 1 deletion holoviews/tests/plotting/plotly/testbarplot.py
Expand Up @@ -60,7 +60,7 @@ def test_bars_grouped_inverted(self):
self.assertEqual(state['layout']['yaxis']['title']['text'], 'A, B')
self.assertEqual(state['layout']['xaxis']['range'], [0, 4])
self.assertEqual(state['layout']['xaxis']['title']['text'], 'y')

def test_bars_stacked(self):
bars = Bars([('A', 1, 1), ('B', 2, 2), ('C', 2, 3), ('C', 1, 4)],
kdims=['A', 'B']).options(stacked=True)
Expand Down Expand Up @@ -92,3 +92,8 @@ def test_bars_stacked_inverted(self):
self.assertEqual(state['layout']['yaxis']['title']['text'], 'A')
self.assertEqual(state['layout']['xaxis']['range'], [0, 7])
self.assertEqual(state['layout']['xaxis']['title']['text'], 'y')

def test_visible(self):
element = Bars([3, 2, 1]).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testbivariateplot.py
Expand Up @@ -41,3 +41,8 @@ def test_bivariate_colorbar(self):
state = self._get_plot_state(bivariate)
trace = state['data'][0]
self.assertFalse(trace['showscale'])

def test_visible(self):
element = Bivariate(([3, 2, 1], [0, 1, 2])).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testboxwhiskerplot.py
Expand Up @@ -57,3 +57,8 @@ def test_boxwhisker_multi_invert_axes(self):
self.assertEqual(state['layout']['yaxis']['title']['text'], 'x')
self.assertEqual(state['layout']['xaxis']['range'], [1, 5])
self.assertEqual(state['layout']['xaxis']['title']['text'], 'y')

def test_visible(self):
element = BoxWhisker(([3, 2, 1], [0, 1, 2])).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testcurveplot.py
Expand Up @@ -52,3 +52,8 @@ def test_curve_line_width(self):
curve = Curve([1, 2, 3]).options(line_width=5)
state = self._get_plot_state(curve)
self.assertEqual(state['data'][0]['line']['width'], 5)

def test_visible(self):
element = Curve([1, 2, 3]).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testdistributionplot.py
Expand Up @@ -18,3 +18,8 @@ def test_distribution_not_filled(self):
self.assertEqual(state['data'][0]['type'], 'scatter')
self.assertEqual(state['data'][0]['mode'], 'lines')
self.assertEqual(state['data'][0].get('fill'), None)

def test_visible(self):
element = Distribution([1, 1.1, 2.1, 3, 2, 1, 2.2]).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
8 changes: 8 additions & 0 deletions holoviews/tests/plotting/plotly/testerrorbarplot.py
Expand Up @@ -26,3 +26,11 @@ def test_errorbars_plot_inverted(self):
self.assertEqual(state['data'][0]['error_x']['arrayminus'], np.array([0.5, 1, 2.25]))
self.assertEqual(state['data'][0]['mode'], 'lines')
self.assertEqual(state['layout']['xaxis']['range'], [0.5, 5.25])

def test_visible(self):
element = ErrorBars(
[(0, 1, 0.5), (1, 2, 1), (2, 3, 2.25)],
vdims=['y', 'y2']
).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testhistogram.py
Expand Up @@ -51,3 +51,8 @@ def test_histogram_plot_styling(self):
state = self._get_plot_state(hist)
marker = state['data'][0]['marker']
self.assert_property_values(marker, props)

def test_visible(self):
element = Histogram((self.edges, self.frequencies)).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
7 changes: 7 additions & 0 deletions holoviews/tests/plotting/plotly/testimageplot.py
Expand Up @@ -34,3 +34,10 @@ def test_image_state_inverted(self):
self.assertEqual(state['data'][0]['zmax'], 4)
self.assertEqual(state['layout']['yaxis']['range'], [0.5, 3.5])
self.assertEqual(state['layout']['xaxis']['range'], [-0.5, 1.5])

def test_visible(self):
element = Image(
([1, 2, 3], [0, 1], np.array([[0, 1, 2], [2, 3, 4]]))
).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testlabelplot.py
Expand Up @@ -45,3 +45,8 @@ def test_labels_yoffset(self):
labels = Labels([(0, 3, 0), (1, 2, 1), (2, 1, 1)]).options(yoffset=0.5)
state = self._get_plot_state(labels)
self.assertEqual(state['data'][0]['y'], np.array([3.5, 2.5, 1.5]))

def test_visible(self):
element = Labels([(0, 3, 0), (1, 2, 1), (2, 1, 1)]).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testpath3d.py
Expand Up @@ -42,3 +42,8 @@ def test_path3D_multi_colors(self):
state = self._get_plot_state(path3D)
self.assertEqual(state['data'][0]['line']['color'], 'red')
self.assertEqual(state['data'][1]['line']['color'], 'blue')

def test_visible(self):
element = Path3D([(0, 1, 0), (1, 2, 1), (2, 3, 2)]).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
7 changes: 7 additions & 0 deletions holoviews/tests/plotting/plotly/testquadmeshplot.py
Expand Up @@ -30,3 +30,10 @@ def test_quadmesh_state_inverted(self):
self.assertEqual(state['data'][0]['zmax'], 4)
self.assertEqual(state['layout']['xaxis']['range'], [-0.5, 1.5])
self.assertEqual(state['layout']['yaxis']['range'], [0.5, 5])

def test_visible(self):
element = QuadMesh(
([1, 2, 4], [0, 1], np.array([[0, 1, 2], [2, 3, 4]]))
).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testscatter3dplot.py
Expand Up @@ -28,3 +28,8 @@ def test_scatter3d_size(self):
scatter = Scatter3D(([0,1], [2,3], [4,5])).options(size='y')
state = self._get_plot_state(scatter)
self.assertEqual(state['data'][0]['marker']['size'], np.array([2, 3]))

def test_visible(self):
element = Scatter3D(([0, 1], [2, 3], [4, 5])).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testscatterplot.py
Expand Up @@ -59,3 +59,8 @@ def test_scatter_selectedpoints(self):
]).options(selectedpoints=[1, 2])
state = self._get_plot_state(scatter)
self.assertEqual(state['data'][0]['selectedpoints'], [1, 2])

def test_visible(self):
element = Scatter([3, 2, 1]).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
8 changes: 8 additions & 0 deletions holoviews/tests/plotting/plotly/testspreadplot.py
Expand Up @@ -29,3 +29,11 @@ def test_spread_fill_between_xs(self):
self.assertEqual(state['data'][1]['fill'], 'tonextx')
self.assertEqual(state['layout']['xaxis']['range'], [0.5, 5.25])
self.assertEqual(state['layout']['yaxis']['range'], [0, 2])

def test_visible(self):
element = Spread(
[(0, 1, 0.5), (1, 2, 1), (2, 3, 2.25)],
vdims=['y', 'y2']
).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
7 changes: 7 additions & 0 deletions holoviews/tests/plotting/plotly/testsurfaceplot.py
Expand Up @@ -31,3 +31,10 @@ def test_surface_colorbar(self):
state = self._get_plot_state(img)
trace = state['data'][0]
self.assertFalse(trace['showscale'])

def test_visible(self):
element = Surface(
([1, 2, 3], [0, 1], np.array([[0, 1, 2], [2, 3, 4]]))
).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testtableplot.py
Expand Up @@ -12,3 +12,8 @@ def test_table_state(self):
self.assertEqual(state['data'][0]['header']['values'], ['x', 'y'])
self.assertEqual(state['data'][0]['cells']['values'],
[['0', '1', '2'], ['1', '2', '3']])

def test_visible(self):
element = Table([(0, 1), (1, 2), (2, 3)], 'x', 'y').options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)
5 changes: 5 additions & 0 deletions holoviews/tests/plotting/plotly/testviolinplot.py
Expand Up @@ -57,3 +57,8 @@ def test_violin_multi_invert_axes(self):
self.assertEqual(state['layout']['yaxis']['title']['text'], 'x')
self.assertEqual(state['layout']['xaxis']['range'], [1, 5])
self.assertEqual(state['layout']['xaxis']['title']['text'], 'y')

def test_visible(self):
element = Violin([1, 1, 2, 3, 3, 4, 5, 5]).options(visible=False)
state = self._get_plot_state(element)
self.assertEqual(state['data'][0]['visible'], False)

0 comments on commit f24eef8

Please sign in to comment.