简体   繁体   中英

How to change spines linewidth in 3D plot?

When you have a 2D plot in matplolib you can change the line width of spines (the containing box) as follows:

fig, ax = plt.subplots()
ax.plot([1,2,3])
spines = ax.spines
[i.set_linewidth(5) for i in spines.values()]

Figure with thick spines: 注意超粗框线

However this same methodology does not work for 3D plots. How could I change the axes line thickness for a 3D plot?

You can do this using the following code. I adapted the idea of accessing the axes in 3D from this answer. If you want to change the thickness of all the grid lines as well, refer to this answer by ImportanceOfBeingErnest

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

for axis in [ax.w_xaxis, ax.w_yaxis, ax.w_zaxis]:
    axis.line.set_linewidth(5)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM