栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

3D Plot with Matplotlib: Hide axes but keep axis-labels?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

3D Plot with Matplotlib: Hide axes but keep axis-labels?

I tried to run your pre, but it is not working in my computer.

Below you can see a solution for plotting a sphere. Basically, I turned the
color of the panes and spines to

alpha=0
by hand and make the ticks to be
empty lists (as you pointed out).

from mpl_toolkits.mplot3d import axes3dimport matplotlib.pyplot as pltfrom matplotlib import rcParamsimport numpy as nprcParams['axes.labelsize'] = 18rcParams['font.family'] = 'serif'rcParams['font.serif'] = ['Computer Modern Roman']rcParams['text.usetex'] = Truefig = plt.figure()ax = fig.add_subplot(111, projection='3d')u = np.linspace(0, 2 * np.pi, 100)v = np.linspace(0, np.pi, 100)x = 10 * np.outer(np.cos(u), np.sin(v))y = 10 * np.outer(np.sin(u), np.sin(v))z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))ax.plot_surface(x, y, z,  rstride=4, cstride=4, color='b')# Get rid of the panesax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))ax.w_yaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))ax.w_zaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))# Get rid of the spinesax.w_xaxis.line.set_color((1.0, 1.0, 1.0, 0.0))ax.w_yaxis.line.set_color((1.0, 1.0, 1.0, 0.0))ax.w_zaxis.line.set_color((1.0, 1.0, 1.0, 0.0))# Get rid of the ticksax.set_xticks([]) ax.set_yticks([]) ax.set_zticks([])# Add the labelsax.set_xlabel('Third dimension' )ax.set_ylabel('Row(s)')ax.set_zlabel('Column(s)')plt.show()

And here is my output



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/455934.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号