Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 537544a

Browse files
committed
Merge pull request #6765 from WeatherGod/mplot3d_classic
Get more rcParams for 3d
1 parent 6b3622a commit 537544a

File tree

2 files changed

+61
-9
lines changed

2 files changed

+61
-9
lines changed

doc/users/whats_new/style_changes.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,19 @@ Legends
127127
data possible.
128128

129129
- The legend now has rounded corners by default.
130+
131+
mplot3d
132+
```````
133+
134+
- mplot3d now obeys some style-related rcParams, rather than using
135+
hard-coded defaults. These include:
136+
137+
- xtick.major.width
138+
- ytick.major.width
139+
- xtick.color
140+
- ytick.color
141+
- axes.linewidth
142+
- axes.edgecolor
143+
- grid.color
144+
- grid.linewidth
145+
- grid.linestyle

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from matplotlib import lines as mlines, axis as maxis, \
1515
patches as mpatches
16+
from matplotlib import rcParams
1617
from . import art3d
1718
from . import proj3d
1819

@@ -80,15 +81,44 @@ def __init__(self, adir, v_intervalx, d_intervalx, axes, *args, **kwargs):
8081
# This is a temporary member variable.
8182
# Do not depend on this existing in future releases!
8283
self._axinfo = self._AXINFO[adir].copy()
83-
self._axinfo.update({'label' : {'va': 'center',
84-
'ha': 'center'},
85-
'tick' : {'inward_factor': 0.2,
86-
'outward_factor': 0.1},
87-
'axisline': {'linewidth': 0.75,
88-
'color': (0, 0, 0, 1)},
89-
'grid' : {'color': (0.9, 0.9, 0.9, 1),
90-
'linewidth': 1.0},
91-
})
84+
if rcParams['_internal.classic_mode']:
85+
self._axinfo.update({'label':
86+
{'va': 'center',
87+
'ha': 'center'},
88+
'tick':
89+
{'inward_factor': 0.2,
90+
'outward_factor': 0.1,
91+
'linewidth': rcParams['lines.linewidth'],
92+
'color': 'k'},
93+
'axisline':
94+
{'linewidth': 0.75,
95+
'color': (0, 0, 0, 1)},
96+
'grid' :
97+
{'color': (0.9, 0.9, 0.9, 1),
98+
'linewidth': 1.0,
99+
'linestyle': '-'},
100+
})
101+
else:
102+
self._axinfo.update({'label' :
103+
{'va': 'center',
104+
'ha': 'center'},
105+
'tick' :
106+
{'inward_factor': 0.2,
107+
'outward_factor': 0.1,
108+
'linewidth': rcParams.get(
109+
adir + 'tick.major.width',
110+
rcParams['xtick.major.width']),
111+
'color': rcParams.get(
112+
adir + 'tick.color',
113+
rcParams['xtick.color'])},
114+
'axisline':
115+
{'linewidth': rcParams['axes.linewidth'],
116+
'color': rcParams['axes.edgecolor']},
117+
'grid' :
118+
{'color': rcParams['grid.color'],
119+
'linewidth': rcParams['grid.linewidth'],
120+
'linestyle': rcParams['grid.linestyle']},
121+
})
92122

93123

94124
maxis.XAxis.__init__(self, axes, *args, **kwargs)
@@ -375,6 +405,10 @@ def draw(self, renderer):
375405
if self.axes._draw_grid:
376406
self.gridlines.set_segments(lines)
377407
self.gridlines.set_color([info['grid']['color']] * len(lines))
408+
self.gridlines.set_linewidth(
409+
[info['grid']['linewidth']] * len(lines))
410+
self.gridlines.set_linestyle(
411+
[info['grid']['linestyle']] * len(lines))
378412
self.gridlines.draw(renderer, project=True)
379413

380414
# Draw ticks
@@ -414,6 +448,8 @@ def draw(self, renderer):
414448
renderer.M)
415449

416450
tick_update_position(tick, (x1, x2), (y1, y2), (lx, ly))
451+
tick.tick1line.set_linewidth(info['tick']['linewidth'])
452+
tick.tick1line.set_color(info['tick']['color'])
417453
tick.set_label1(label)
418454
tick.set_label2(label)
419455
tick.draw(renderer)

0 commit comments

Comments
 (0)