Skip to content

Commit 40a28df

Browse files
committed
Add notes and tests for mixed inputs.
1 parent 00eb9c2 commit 40a28df

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

bokeh/tests/test_plotting.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,35 @@ def color_only_checks(self, p, rgb):
148148
def line_color_input_checks(self, p, rgb):
149149
"""Helper method for checks specific to line_color= only input."""
150150
p.circle([1, 2, 3], [1, 2, 3], line_color=rgb)
151-
152151
self.assertTupleEqual(p.renderers[-1].glyph.line_color, rgb)
153-
154152
# should always be an integer by the time it is added to property
155153
[self.assertIsInstance(v, int) for v in p.renderers[-1].glyph.line_color[0:3]]
156154

155+
def test_mixed_inputs(self):
156+
"""Helper method to test mixed global and specific color args."""
157+
158+
p = plt.figure()
159+
rgb = (100, 0, 0)
160+
rgb_other = (0, 100, 0)
161+
alpha1 = 0.5
162+
alpha2 = 0.75
163+
164+
# color/line_color
165+
p.circle([1, 2, 3], [1, 2, 3], color=rgb, line_color=rgb_other)
166+
self.assertTupleEqual(p.renderers[-1].glyph.fill_color, rgb)
167+
self.assertTupleEqual(p.renderers[-1].glyph.line_color, rgb_other)
168+
169+
# color/fill_color
170+
p.circle([1, 2, 3], [1, 2, 3], color=rgb, fill_color=rgb_other)
171+
self.assertTupleEqual(p.renderers[-1].glyph.line_color, rgb)
172+
self.assertTupleEqual(p.renderers[-1].glyph.fill_color, rgb_other)
173+
174+
# alpha/line_alpha
175+
p.circle([1, 2, 3], [1, 2, 3], color=rgb, alpha=alpha1,
176+
line_alpha=alpha2)
177+
self.assertEqual(p.renderers[-1].glyph.line_alpha, alpha2)
178+
self.assertEqual(p.renderers[-1].glyph.fill_alpha, alpha1)
179+
157180
def test_color_input_float(self):
158181
"""Test input of rgb with float values."""
159182
rgbs = [(100., 100., 100.), (50., 100., 50., 0.5)]

sphinx/source/docs/user_guide/styling.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ the inputs for line and fill alphas:
112112
p.yaxis[0].axis_label = "Line Options"
113113
show(p)
114114

115+
.. note::
116+
If using the |bokeh.plotting| interface, another option is to specify
117+
``color`` and/or ``alpha`` as a keyword, as well as the demonstrated color
118+
properties. These inputs work by applying the provided value to both of the
119+
corresponding ``line`` and ``fill`` properties. However, you can still
120+
provide ``fill|line_alpha`` or ``fill|line_color`` in combination with
121+
the ``color``/``alpha`` keywords, and the former will take precedence.
115122

116123
.. _userguide_styling_selecting:
117124

0 commit comments

Comments
 (0)