【发布时间】:2021-09-19 15:39:21
【问题描述】:
以下是我尝试使用 plotly 在地图上显示的输入文件。
data.csv
lat,long,type
-7.80715,110.371203,1
-7.791087,110.368346,3
-7.778744,110.365107,7
-7.77877,110.365379,4
脚本有效,但比例以连续格式显示。我试图将type 列转换为here 提到的文本,但我无法让它工作。有没有更简单的方法来解决这个问题?
df = pd.read_csv("data.csv").dropna()
fig = go.Figure(go.Scattermapbox(
lat=df["lat"].tolist(),
lon=df["long"].tolist(),
mode='markers',
text=df['type'].tolist(),
marker=go.scattermapbox.Marker(
size=10,
color=df['type'],
showscale=True
),
))
fig.show()
【问题讨论】:
-
不知道是不是这个原因,但是你用
df[type]而不是df['type'] -
抱歉,打错了。
标签: python plotly plotly-python