diff --git a/holoviews/plotting/bokeh/__init__.py b/holoviews/plotting/bokeh/__init__.py index bb723578d3..24d667ba1a 100644 --- a/holoviews/plotting/bokeh/__init__.py +++ b/holoviews/plotting/bokeh/__init__.py @@ -205,7 +205,7 @@ def colormap_generator(palette): options.VSpan = Options('style', color=Cycle(), alpha=0.5) options.HSpan = Options('style', color=Cycle(), alpha=0.5) options.Arrow = Options('style', arrow_size=10) -options.Labels = Options('style', text_align='center', text_baseline='middle') +options.Labels = Options('style', text_color=Cycle(), text_align='center', text_baseline='middle') # Graphs options.Graph = Options( diff --git a/holoviews/plotting/mpl/__init__.py b/holoviews/plotting/mpl/__init__.py index a19e12b884..cf64021bab 100644 --- a/holoviews/plotting/mpl/__init__.py +++ b/holoviews/plotting/mpl/__init__.py @@ -271,6 +271,7 @@ def grid_selector(grid): options.VSpan = Options('style', alpha=0.5, facecolor=Cycle()) options.HSpan = Options('style', alpha=0.5, facecolor=Cycle()) options.Spline = Options('style', edgecolor=Cycle()) +options.Labels = Options('style', color=Cycle()) options.Arrow = Options('style', color='k', linewidth=2, textsize=13) # Paths diff --git a/holoviews/plotting/plotly/__init__.py b/holoviews/plotting/plotly/__init__.py index aff36fb46f..e95b9cfca4 100644 --- a/holoviews/plotting/plotly/__init__.py +++ b/holoviews/plotting/plotly/__init__.py @@ -136,6 +136,7 @@ # Annotations options.VSpan = Options('style', fillcolor=Cycle(), opacity=0.5) options.HSpan = Options('style', fillcolor=Cycle(), opacity=0.5) +options.Labels = Options('style', color=Cycle()) # Shapes options.Rectangles = Options('style', line_color=dflt_shape_line_color) diff --git a/holoviews/tests/plotting/bokeh/test_labels.py b/holoviews/tests/plotting/bokeh/test_labels.py index 565f4807c8..ffdc2f15f1 100644 --- a/holoviews/tests/plotting/bokeh/test_labels.py +++ b/holoviews/tests/plotting/bokeh/test_labels.py @@ -2,7 +2,9 @@ from holoviews.core.dimension import Dimension from holoviews.element import Labels +from holoviews.core.spaces import HoloMap from holoviews.plotting.bokeh.util import property_to_dict +from holoviews.core.options import Cycle from bokeh.models import LinearColorMapper, CategoricalColorMapper @@ -186,3 +188,12 @@ def test_labels_color_index_color_clash(self): "color_index.\n" ) self.assertEqual(log_msg, warning) + + def test_labels_text_color_cycle(self): + hm = HoloMap( + {i: Labels([ + (0, 0 + i, "Label 1"), + (1, 1 + i, "Label 2") + ]) for i in range(3)} + ).overlay() + assert isinstance(hm[0].opts["text_color"], Cycle) diff --git a/holoviews/tests/plotting/matplotlib/test_labels.py b/holoviews/tests/plotting/matplotlib/test_labels.py index 040f31e4a7..4ae9c4a78f 100644 --- a/holoviews/tests/plotting/matplotlib/test_labels.py +++ b/holoviews/tests/plotting/matplotlib/test_labels.py @@ -3,6 +3,7 @@ from holoviews.core.dimension import Dimension from holoviews.core.spaces import HoloMap from holoviews.element import Labels +from holoviews.core.options import Cycle from holoviews.plotting.util import rgb2hex from .test_plot import TestMPLPlot, mpl_renderer @@ -171,3 +172,12 @@ def test_label_rotation_op_update(self): artist = plot.handles['artist'] self.assertEqual([a.get_rotation() for a in artist], [30, 120, 60]) + + def test_labels_text_color_cycle(self): + hm = HoloMap( + {i: Labels([ + (0, 0 + i, "Label 1"), + (1, 1 + i, "Label 2") + ]) for i in range(3)} + ).overlay() + assert isinstance(hm[0].opts["color"], Cycle) diff --git a/holoviews/tests/plotting/plotly/test_labelplot.py b/holoviews/tests/plotting/plotly/test_labelplot.py index bf66aa66f5..6c510001ed 100644 --- a/holoviews/tests/plotting/plotly/test_labelplot.py +++ b/holoviews/tests/plotting/plotly/test_labelplot.py @@ -1,6 +1,8 @@ import numpy as np from holoviews.element import Labels, Tiles +from holoviews.core.options import Cycle +from holoviews.core.spaces import HoloMap from .test_plot import TestPlotlyPlot @@ -132,3 +134,12 @@ def test_visible(self): element = Tiles("") * Labels([(0, 3, 0), (1, 2, 1), (2, 1, 1)]).opts(visible=False) state = self._get_plot_state(element) self.assertEqual(state['data'][1]['visible'], False) + + def test_labels_text_color_cycle(self): + hm = HoloMap( + {i: Labels([ + (0, 0 + i, "Label 1"), + (1, 1 + i, "Label 2") + ]) for i in range(3)} + ).overlay() + assert isinstance(hm[0].opts["color"], Cycle)