我是Dash和python的新手,我只是在练习一个包含映射图的示例,而在执行程序时却遇到语法错误。谁可以帮我这个事?参考: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);
});
答案 0 :(得分:1)
这段代码不是python,var吗? “;”?没有适当的意图。显然,在要求SO之前,您需要做更多的工作