File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ def set_default_locators_and_formatters(self, axis):
69
69
axis .set_major_formatter (ScalarFormatter ())
70
70
axis .set_minor_formatter (NullFormatter ())
71
71
# update the minor locator for x and y axis based on rcParams
72
- if rcParams ['xtick.minor.visible' ]:
72
+ if (axis .axis_name == 'x' and rcParams ['xtick.minor.visible' ]
73
+ or axis .axis_name == 'y' and rcParams ['ytick.minor.visible' ]):
73
74
axis .set_minor_locator (AutoMinorLocator ())
74
75
else :
75
76
axis .set_minor_locator (NullLocator ())
Original file line number Diff line number Diff line change @@ -839,3 +839,21 @@ def test_minlocator_type():
839
839
fig , ax = plt .subplots ()
840
840
with pytest .raises (TypeError ):
841
841
ax .xaxis .set_minor_locator (matplotlib .ticker .LogFormatter ())
842
+
843
+
844
+ def test_minorticks_rc ():
845
+ fig = plt .figure ()
846
+
847
+ def minorticksubplot (xminor , yminor , i ):
848
+ rc = {'xtick.minor.visible' : xminor ,
849
+ 'ytick.minor.visible' : yminor }
850
+ with plt .rc_context (rc = rc ):
851
+ ax = fig .add_subplot (2 , 2 , i )
852
+
853
+ assert (len (ax .xaxis .get_minor_ticks ()) > 0 ) == xminor
854
+ assert (len (ax .yaxis .get_minor_ticks ()) > 0 ) == yminor
855
+
856
+ minorticksubplot (False , False , 1 )
857
+ minorticksubplot (True , False , 2 )
858
+ minorticksubplot (False , True , 3 )
859
+ minorticksubplot (True , True , 4 )
You can’t perform that action at this time.
0 commit comments