二维数组可视化,求大家指导一下,给新生解答一下

img

使用matplotlib画一个$\sqrt{x^2 + y^2}$的三维网格图,参考代码如下,

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = plt.axes(projection="3d")
x = np.arange(-5, 5, 0.1)
y = np.arange(-5, 5, 0.1)
z = np.sqrt(x**2+y**2)
X, Y = np.meshgrid(x, y)    # 2生成绘制3D图形所需的网络数据
Z = np.sqrt(X**2+Y**2)
ax.plot3D(x,y,z,'gray')
ax.plot_surface(X, Y, Z, alpha=0.5, cmap="winter")  # 生成表面,alpha用于控制透明度
ax.set_xlabel("X")  # 设置X、Y、Z 轴及坐标范围
ax.set_xlim(-6, 6) 
ax.set_ylabel("Y")
ax.set_ylim(-6, 6)
ax.set_zlabel("Z")
plt.title('Image plot of $\sqrt{x^2 + y^2}$ for a grid of values')
plt.show()

(5条消息) pandas 常见绘图总结_平凡简单的执着-CSDN博客_pandas 画图 pandas 常见绘图总结文章目录pandas 常见绘图总结前言一 设置字体和显示中文二 pandas 可视化(0.25.3版本)1 线形图2 条形图2.1 垂直条形图2.2 水平条形图3 饼图4 散点图4.1 普通散点图4.2 气泡图5 面积图6 箱线图7 直方图8 核密度曲线9 hexbin(六边形图)前言pandas的强大让人毋庸置疑,一个集数据审阅、处理、分析、可视化于一身的工具,非... https://blog.csdn.net/qq_40195360/article/details/103710930