在Python中绘制线框球体以隐藏后向子午线和平行线 [英] Plotting a wireframe sphere in Python hidding backward meridians and parallels

查看:63
本文介绍了在Python中绘制线框球体以隐藏后向子午线和平行线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个问题中,我们展示了如何绘制(以及许多其他东西)一个球体:

In this question we are shown how to plot (among many other things) a sphere: Python/matplotlib : plotting a 3d cube, a sphere and a vector?

It's very nice but I would like to plot the wireframe sphere in such a way that the parallels and meridians that are outside the line of vision (hidden by the sphere itself) don't appear. Is that possible with a python script?

Thanks.

解决方案

The idea of a wireframe plot is to make is see-through such that features behind the object are still visible.
So instead of a wireframe you probably want to plot a surface plot:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_aspect("equal")

# draw sphere
u, v = np.mgrid[0:2*np.pi:20j, 0:np.pi:10j]
x = np.cos(u)*np.sin(v)
y = np.sin(u)*np.sin(v)
z = np.cos(v)
ax.plot_surface(x, y, z, color="w", edgecolor="r")

plt.show()

这篇关于在Python中绘制线框球体以隐藏后向子午线和平行线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆