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

Function test_grid_rcparams

lib/matplotlib/tests/test_axis.py:88–113  ·  view source on GitHub ↗

Tests that `grid.major/minor.*` overwrites `grid.*` in rcParams.

()

Source from the content-addressed store, hash-verified

86
87
88def test_grid_rcparams():
89 """Tests that `grid.major/minor.*` overwrites `grid.*` in rcParams."""
90 plt.rcParams.update({
91 "axes.grid": True, "axes.grid.which": "both",
92 "ytick.minor.visible": True, "xtick.minor.visible": True,
93 })
94 def_linewidth = plt.rcParams["grid.linewidth"]
95 def_linestyle = plt.rcParams["grid.linestyle"]
96 def_alpha = plt.rcParams["grid.alpha"]
97
98 plt.rcParams.update({
99 "grid.color": "gray", "grid.minor.color": "red",
100 "grid.major.linestyle": ":", "grid.major.linewidth": 2,
101 "grid.minor.alpha": 0.6,
102 })
103 _, ax = plt.subplots()
104 ax.plot([0, 1])
105
106 assert ax.xaxis.get_major_ticks()[0].gridline.get_color() == "gray"
107 assert ax.xaxis.get_minor_ticks()[0].gridline.get_color() == "red"
108 assert ax.xaxis.get_major_ticks()[0].gridline.get_linewidth() == 2
109 assert ax.xaxis.get_minor_ticks()[0].gridline.get_linewidth() == def_linewidth
110 assert ax.xaxis.get_major_ticks()[0].gridline.get_linestyle() == ":"
111 assert ax.xaxis.get_minor_ticks()[0].gridline.get_linestyle() == def_linestyle
112 assert ax.xaxis.get_major_ticks()[0].gridline.get_alpha() == def_alpha
113 assert ax.xaxis.get_minor_ticks()[0].gridline.get_alpha() == 0.6
114
115
116def test_set_ticks_emits_lim_changed():

Callers

nothing calls this directly

Calls 9

updateMethod · 0.45
subplotsMethod · 0.45
plotMethod · 0.45
get_colorMethod · 0.45
get_major_ticksMethod · 0.45
get_minor_ticksMethod · 0.45
get_linewidthMethod · 0.45
get_linestyleMethod · 0.45
get_alphaMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…