# Lines on maps with PlotlyJS

**URL:** <https://discourse.julialang.org/t/lines-on-maps-with-plotlyjs/86000>\
**Category:** Visualization\
**Tags:** plotlyjs\
**Created:** [August 19, 2022, 12:20pm UTC](https://discourse.julialang.org/t/lines-on-maps-with-plotlyjs/86000 "2022-08-19T12:20:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lgo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lgo/32/48751_2.png) [@lgo](https://discourse.julialang.org/u/lgo)\
**Post date:** [August 19, 2022, 12:20pm UTC](https://discourse.julialang.org/t/lines-on-maps-with-plotlyjs/86000/1 "2022-08-19T12:20:06Z")

</div>

I want to use PlotlyJS to create lines on maps as [explained here](https://plotly.com/javascript/lines-on-maps/). I build on the [maps example](http://juliaplots.org/PlotlyJS.jl/stable/examples/maps/) from the PlotlyJS documentation to “translate” the JavaScript code into the Julia/PlotlyJS notation, but the resulting map does not show any lines, but does not produce any errors either. I’m using Julia 1.7.

> using PlotlyJS, DataFrames, CSV
> 
> nm = tempname()  
> url = “[https://raw.githubusercontent.com/plotly/datasets/c34aaa0b1b3cddad335173cb7bc0181897201ee6/2011\_february\_aa\_flight\_paths.csv](https://raw.githubusercontent.com/plotly/datasets/c34aaa0b1b3cddad335173cb7bc0181897201ee6/2011_february_aa_flight_paths.csv)”  
> download(url, nm)  
> cord = CSV.read(nm,DataFrame)
> 
> data = scattergeo(;locationmode=“USA-states”,  
> lon = hcat(cord[!,:start\_lon], cord[!,:end\_lon]),  
> lat = hcat(cord[!,:start\_lat], cord[!,:end\_lat]),  
> mode = “lines”,  
> line\_width = 5,  
> line\_color = “red”,  
> opacityValue = 2  
> )
> 
> geo = attr(scope=“north america”,  
> projection\_type=“azimuthal equal area”,  
> showland=true,  
> landcolor=“rgb(217, 217, 217)”,  
> subunitwidth=1,  
> countrywidth=1,  
> subunitcolor=“rgb(255,255,255)”,  
> countrycolor=“rgb(255,255,255)”)
> 
> layout = Layout(;title=“lines”, showlegend=false, geo=geo)  
> plot(data, layout)

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [August 19, 2022, 1:54pm UTC](https://discourse.julialang.org/t/lines-on-maps-with-plotlyjs/86000/2 "2022-08-19T13:54:45Z")

</div>

Hi Leonard, Here is how I would translate that example:

```julia
using PlotlyJS, DataFrames, CSV

nm = tempname()
url = "https://raw.githubusercontent.com/plotly/datasets/c34aaa0b1b3cddad335173cb7bc0181897201ee6/2011_february_aa_flight_paths.csv"
download(url, nm)
cord = CSV.read(nm,DataFrame)

M = maximum(cord[:,:cnt])

trace_data = [ scattergeo(;locationmode="USA-states",
    lon = [cord[i,:start_lon], cord[i,:end_lon]],
    lat = [cord[i,:start_lat], cord[i,:end_lat]],
    mode = "lines",
    line_width = 2,
    line_color = "red",
    opacity = cord[i,:cnt]/M
) for i in 1:nrow(cord)];

geo = attr(scope="north america",
    projection_type="azimuthal equal area",
    showland=true,
    landcolor="rgb(243,243,243)",
    countrycolor="rgb(204,204,204)",
    subunitwidth=1,
    countrywidth=1,
)

layout = Layout(;title="Feb. 2011 American Airline flight paths", showlegend=false, geo=geo)
plot(trace_data, layout)

```
