【发布时间】:2022-01-26 20:00:55
【问题描述】:
我正在尝试从 CSV 文件中绘制大量纬度、经度、海拔和 EMF 值。 CSV 文件如下所示
dat,latitude,longitude,EMF,Elevation
1/20/2022 7:18:17,59.39556688,18.12773272,0,18.17260262
1/20/2022 7:18:18,59.39556685,18.12773267,0,18.17260262
1/20/2022 7:18:19,59.39556684,18.12773265,0,18.17260262
1/20/2022 7:18:20,59.39556693,18.1277326,4.1,18.17260262
1/20/2022 7:18:21,59.39556698,18.12773191,4,18.17260262
1/20/2022 7:18:22,59.39556714,18.1277315,4.1,18.17260262
1/20/2022 7:18:23,59.39556728,18.12773191,4.1,18.17260262
1/20/2022 7:18:24,59.39556718,18.12773088,4,18.17260262
1/20/2022 7:18:25,59.39556755,18.12773013,4.1,18.17260262
1/20/2022 7:18:26,59.39556755,18.1277296,131,18.17260262
1/20/2022 7:18:27,59.39556729,18.12772922,125.9,18.17260262
1/20/2022 7:18:28,59.39556682,18.1277278,9,18.17260262
1/20/2022 7:18:29,59.39556684,18.1277263,4.1,18.17260262
我想根据 EMF 值用不同的颜色来表示它们。
我的代码是这样的
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import pandas
points = pandas.read_csv('data.csv')
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
latitude = points['latitude'].values
longitude = points['longitude'].values
EMF = points['EMF'].values
plt.ticklabel_format(useOffset=False)
ax.scatter(latitude, longitude, EMF, c='r', marker='o')
plt.show()
我该怎么做?
【问题讨论】:
-
c=EMF有什么问题? -
@Mr. T 哇,这确实有效……太好了!不能很好地控制色阶,但它确实显示为渐变。在插入 c 之前,您可能可以对 EMF 进行一些转换。
标签: python pandas csv matplotlib plot