python - matplotlib 3D:多行
问题描述
使用 matplotlib,是否可以在不使用 for 循环的情况下绘制多条线?因为数据完全不同。
from mpl_toolkits import mplot3d
import pandas as pd
import numpy as np
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
从excel中获取数据
第一行
df1 = pd.read_excel (r'C:/Users/pathar.xlsx', sheet_name= '1')
#print (df1)
zline = df1['Simul_1']
yline = df1['land']
xline = df1['Dis_peak_1']
图尺寸
fig = plt.figure()
fig.set_figwidth(15)
fig.set_figheight(12)
然后绘制第一条带点的线
ax = plt.axes(projection='3d')
ax.plot3D(xline, yline, zline,'red')
ax.view_init(20, -70)
ax.scatter3D(xline, yline, zline,c='k');
第二行
df2 = pd.read_excel (r'C:/Users/pathar.xlsx', sheet_name= '2')
#print (df2)
zline2 = df2['Simul_2']
yline2 = df2['land']
xline2 = df2['Dis_peak_2']
fig = plt.figure()
fig.set_figwidth(15)
fig.set_figheight(12)
ax = plt.axes(projection='3d')
ax.plot3D(xline2, yline2, zline2,'red')
ax.view_init(20, -70)
ax.scatter3D(xline2, yline2, zline2,c='k');
但是当我使用相同的方法绘制第二行时,它不起作用。虽然它适用于 2D 情节
解决方案
推荐阅读
- c++ - OpenGL:在帧中回收帧缓冲区会损害性能吗?
- influxdb - 将多个值插入到 influxdb
- python - 减少 matplotlib 中的 y 刻度,字符串错误
- node.js - anagrams 数组程序和数组组结果
- swift - 为什么我存档的 Swift 应用程序看起来路径错误?
- javascript - JS 应该在页面重新加载后保持它的工作
- css - 如何在桌子的每个 tr 上制作圆角
- tornadofx - 动态创建时是否有针对重复选项卡的修复?
- virtual-machine - 如何在 Xen 客户机中启用桥接网络?
- c - 用 C 实现 - 2018 年代码的出现:第 1_2 天