gpt4 book ai didi

python - 使用破折号创建 map 出现语法错误

转载 作者:行者123 更新时间:2023-12-01 08:22:18 25 4
gpt4 key购买 nike

我是 Dash 和 python 的新手,我只是练习一个包含 map 的示例,在执行程序时我遇到语法错误。谁可以帮我这个事?引用:https://codepen.io/Dorkaitz/pen/QmooBK下面是我的代码:

import plotly.plotly as py
import plotly.figure_factory as ff
import pandas as pd

Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv',

function(err, rows){
function unpack(rows, key) {
return rows.map(function(row) { return row[key]; });
}

var scl = [[0,'rgb(5, 10, 172)'],[0.35,'rgb(40, 60, 190)'],[0.5,'rgb(70, 100, 245)'], [0.6,'rgb(90, 120, 245)'],[0.7,'rgb(106, 137, 247)'],[1,'rgb(220, 220, 220)']];

var data = [{
type:'scattergeo',
locationmode: 'USA-states',
lon: unpack(rows, 'long'),
lat: unpack(rows, 'lat'),
hoverinfor: unpack(rows, 'airport'),
text: unpack(rows, 'airport'),
mode: 'markers',
marker: {
size: 8,
opacity: 0.8,
reversescale: true,
autocolorscale: false,
symbol: 'round',
line: {
width: 1,
color: 'rgb(102,102,102)'
},
colorscale: scl,
cmin: 0,
color: unpack(rows, 'cnt'),
}
}];


var layout = {
colorbar: false,
autoscale: 1,
showgrid: 1,
margin: {t: 0, l: 0, r: 0, b: 0},
geo: {
autoscale: 1,
scope: "world",
projection: {
type: 'mercator',
},
lonaxis: { range: [-169, 191] },
lataxis: { range: [-3, 90] },
showframe: false,
showlegend: false,
showland: true,
showocean: true,
showscale: true,
landcolor: 'rgb(62,71,80)',
oceancolor: 'rgb(33,43,54)',
subunitcolor: 'rgb(217,217,217)',
countrycolor: 'rgb(217,217,217)',
countrywidth: 0.5,
subunitwidth: 0.5,
fixedrange: true,
scrollzoom: false
}
};

Plotly.plot(myDiv, data, layout, {scrollZoom: false});

var geo = Plotly.plot;
console.log(geo);

});

最佳答案

这段代码不是Python,var? “;”?没有正确缩进。显然,在询问 SO 之前您需要做更多的工作

关于python - 使用破折号创建 map 出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54546197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com