MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_stem_markerfmt

Function test_stem_markerfmt

lib/matplotlib/tests/test_axes.py:5007–5069  ·  view source on GitHub ↗

Test that stem(..., markerfmt=...) produces the intended markers.

()

Source from the content-addressed store, hash-verified

5005
5006
5007def test_stem_markerfmt():
5008 """Test that stem(..., markerfmt=...) produces the intended markers."""
5009 def _assert_equal(stem_container, linecolor=None, markercolor=None,
5010 marker=None):
5011 """
5012 Check that the given StemContainer has the properties listed as
5013 keyword-arguments.
5014 """
5015 if linecolor is not None:
5016 assert mcolors.same_color(
5017 stem_container.stemlines.get_color(),
5018 linecolor)
5019 if markercolor is not None:
5020 assert mcolors.same_color(
5021 stem_container.markerline.get_color(),
5022 markercolor)
5023 if marker is not None:
5024 assert stem_container.markerline.get_marker() == marker
5025 assert stem_container.markerline.get_linestyle() == 'None'
5026
5027 fig, ax = plt.subplots()
5028
5029 x = [1, 3, 5]
5030 y = [9, 8, 7]
5031
5032 # no linefmt
5033 _assert_equal(ax.stem(x, y), markercolor='C0', marker='o')
5034 _assert_equal(ax.stem(x, y, markerfmt='x'), markercolor='C0', marker='x')
5035 _assert_equal(ax.stem(x, y, markerfmt='rx'), markercolor='r', marker='x')
5036
5037 # positional linefmt
5038 _assert_equal(
5039 ax.stem(x, y, 'r'), # marker color follows linefmt if not given
5040 linecolor='r', markercolor='r', marker='o')
5041 _assert_equal(
5042 ax.stem(x, y, 'rx'), # the marker is currently not taken from linefmt
5043 linecolor='r', markercolor='r', marker='o')
5044 _assert_equal(
5045 ax.stem(x, y, 'r', markerfmt='x'), # only marker type specified
5046 linecolor='r', markercolor='r', marker='x')
5047 _assert_equal(
5048 ax.stem(x, y, 'r', markerfmt='g'), # only marker color specified
5049 linecolor='r', markercolor='g', marker='o')
5050 _assert_equal(
5051 ax.stem(x, y, 'r', markerfmt='gx'), # marker type and color specified
5052 linecolor='r', markercolor='g', marker='x')
5053 _assert_equal(
5054 ax.stem(x, y, 'r', markerfmt=' '), # markerfmt=' ' for no marker
5055 linecolor='r', markercolor='r', marker='None')
5056 _assert_equal(
5057 ax.stem(x, y, 'r', markerfmt=''), # markerfmt='' for no marker
5058 linecolor='r', markercolor='r', marker='None')
5059
5060 # with linefmt kwarg
5061 _assert_equal(
5062 ax.stem(x, y, linefmt='r'),
5063 linecolor='r', markercolor='r', marker='o')
5064 _assert_equal(

Callers

nothing calls this directly

Calls 3

_assert_equalFunction · 0.85
subplotsMethod · 0.45
stemMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…