PyCharm配置 Jupyter Notebook
这个文章很全
PyCharm配置 Jupyter Notebook
plotly方法
终端安装:
pip install plotly
import plotly.graph_objects as go
import numpy as np
# 示例数据
X = np.linspace(-5, 5, 100)
Y = np.linspace(-5, 5, 100)
X, Y = np.meshgrid(X, Y)
Z = np.sin(np.sqrt(X**2 + Y**2))
fig = go.Figure(data=[go.Surface(z=Z, x=X, y=Y)])
fig.update_layout(title='3D Surface Plot', autosize=False, width=700, height=700)
fig.show()
会直接在界面显示
matplotlib方法
需要安装pyqt,终端运行:
conda install pyqt
import matplotlib
matplotlib.use('Qt5Agg') # 或者 'TkAgg'
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# 示例数据
X = np.linspace(-5, 5, 100)
Y = np.linspace(-5, 5, 100)
X, Y = np.meshgrid(X, Y)
Z = np.sin(np.sqrt(X**2 + Y**2))
ax.plot_surface(X, Y, Z, cmap='viridis')
plt.show()
结果会在窗口显示
补充
很多方法说的是这个取消勾选,但是对我遇到的这种问题不适用
打赏博主
制作不易,如果有能帮到你,可以打赏博主一瓶可乐