Python draws a variety of colorful triangular surfaces

import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
from mpl_toolkits.mplot3d import Axes3D

plt.style.use('seaborn-darkgrid')

n_radii = 8
n_angles = 36
# Make radii and angles spaces
radii = np.linspace(0.125, 1.0, n_radii)
angles = np.linspace(0, 2*np.pi, n_angles, endpoint=False)[..., np.newaxis]

# Convert polar (radii, angles) coords to cartesian (x, y) coords.
x = np.append(0, (radii*np.cos(angles)).flatten())
y = np.append(0, (radii*np.sin(angles)).flatten())
z = np.sin(-x*y)

# Plot
fig, ax = plt.subplots(subplot_kw={
    
    'projection': '3d'})
ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.Blues)

ax.set(xticklabels=[],
       yticklabels=[],
       zticklabels=[])

plt.show()

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.PuBuGn_r)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.winter)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.viridis)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.twilight_r)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.terrain_r)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.tab20c)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.tab20b)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.tab20)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.tab20)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.seismic)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.rainbow)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.prism)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.ocean_r)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.nipy_spectral_r)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.nipy_spectral)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.magma)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.jet_r)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.jet)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.inferno)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.hsv_r)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.hsv)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.gnuplot_r)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.gnuplot2_r)

insert image description here

ax.plot_trisurf(x, y, z, vmin=z.min() * 2, cmap=cm.gnuplot2)

insert image description here
References: https://matplotlib.org/stable/plot_types/3D/trisurf3d_simple.html

Development tools: Visual Studio 2022 and WeChat Alt+A screenshot tool

Guess you like

Origin blog.csdn.net/m0_38127487/article/details/132196383