0

I am having a problem. I imported needed libraries

aerial = pd.read_csv("C://Users//bilim//Python//DATAI Team//3) Data Visualization//operations.csv")

import plotly.plotly as py
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)
import plotly.graph_objs as go


# ATTACK
aerial["color"] = ""
aerial.color[aerial.Country == "USA"] = "rgb(0,116,217)"
aerial.color[aerial.Country == "GREAT BRITAIN"] = "rgb(255,65,54)"
aerial.color[aerial.Country == "NEW ZEALAND"] = "rgb(133,20,75)"
aerial.color[aerial.Country == "SOUTH AFRICA"] = "rgb(255,133,27)"

data = [dict(
    type='scattergeo',
    lon = aerial['Takeoff Longitude'],
    lat = aerial['Takeoff Latitude'],
    hoverinfo = 'text', 
    text = "Country: " + aerial.Country + " Takeoff Location: "+aerial["Takeoff Location"]+" Takeoff Base: " + aerial['Takeoff Base'],
    mode = 'markers',
    marker=dict(
        sizemode = 'area',
        sizeref = 1,
        size= 10 ,
        line = dict(width=1,color = "white"),
        color = aerial["color"],
        opacity = 0.7),
)]

layout = dict(
    title = 'Countries Take Off Bases ',
    hovermode='closest',
    geo = dict(showframe=False, showland=True, showcoastlines=True, showcountries=True,
           countrywidth=1, projection=dict(type='Mercator'),
          landcolor = 'rgb(217, 217, 217)',
          subunitwidth=1,
          showlakes = True,
          lakecolor = 'rgb(255, 255, 255)',
          countrycolor="rgb(5, 5, 5)")
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)

The error is: ValueError: Invalid element(s) received for the 'color' property of scattergeo.marker Invalid elements include: ['', '', '', '', '', '', '', '', '', '']

0

1 Answer 1

1

The error comes from this line of code: aerial["color"] = "". You would need to assign some values to aerial["color"] (e.g. ["red", "blue", "green", ...]) if you actually intend to use it to define the marker colors.

Sign up to request clarification or add additional context in comments.

2 Comments

but i assign it in "data". its as color = aerial["color"]
In your code aerial["color"] is just an empty string (i.e. ""), it's not a color or a list of colors. You need to define aerial["color"] before using it as a marker color.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.