简体   繁体   English

使用Matplotlib3D线框创建海面图

[英]Create Sea Surface Plot with Matplotlib3D wireframe

I want to create a plot which looks similar to: https://www.shutterstock.com/de/image-vector/vector-abstract-3d-wave-wireframe-surrounding-445020520 I use something like the wire frame demo with a different background (best case a blue color gradient): 我想创建一个类似于以下内容的图: https : //www.shutterstock.com/de/image-vector/vector-abstract-3d-wave-wireframe-surrounding-445020520我使用类似线框演示的东西不同的背景(最好是蓝色渐变):

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d', axisbg='blue')

# Grab some test data, e.g.gcreate noisy sea surface data
X, Y, Z = axes3d.get_test_data(0.05)

# Plot a basic white wireframe for the surface
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10, color='white')

plt.show()

What would you take to make this more look like the example? 您将如何使它看起来更像示例?

Cheers Bene 干杯

Here is one (out of many) options. 这是(多个)选项之一。 Using a surface plot in the background of the wireframe can give the plot some shading and make it more look like the picture. 在线框的背景中使用表面图可以使该图有一些阴影并使它看起来更像图片。

在此处输入图片说明

import numpy as np
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d', facecolor='#1a5a98')
plt.subplots_adjust(0,0,1,1)
fig.patch.set_color('#1a5a98')

#Generate some data
x = np.linspace(0,500,501)/(9*np.pi)
X,Y = np.meshgrid(x,x)
f = lambda x,y: np.sin(x+y**0.2)*np.cos(y-x**0.4)
Z = f(X,Y)

# plot surface, for nice shading
ax.plot_surface(X, Y, Z, rstride=10, cstride=10)
# plot wireframe for white lines on top
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10, color='white', linewidth=0.5)
#set axis off
ax.axis("off")
ax.set_xlim(6.42,11.17)
ax.set_ylim(6.42,11.17)
ax.set_zlim(-6,6)
ax.view_init(elev=25, azim=-88)
plt.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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