Skip to content Skip to sidebar Skip to footer

Error When Plotting Scatter Plot With Gmplot In Python

I want to plot scatter plot using gmplot lib in Python. However, I want to make marker_size different for each plot (for each coordinate). I wrote a code and I got this error: Type

Solution 1:

I think your problem is with the line:

gmap.scatter(coordinate_lats, coordinate_lons, 'red', size = marker_size, marker = False)

While you can pass an iterable with "coordinate_lats" and "coordinate_lons" I believe the arg "size" is expecting a float parameter, not a tuple (hence the error). I not sure it was designed to allow for every individual point to be colored different, it's probably expecting the whole series to be the same size. You could probably just loop over this call to get your desired effect. Like so:

.
.
.
# Scatter points
coordinate_lats, coordinate_lons, marker_size = zip(*coordinate_list)

# Defult map location
gmap = gmplot.GoogleMapPlotter(40.7423543, -73.98915076, 13)

#Scatter dots on the mapfor coord_lat, coord_lon, m_size inzip(coordinate_lats, coordinate_lons, marker_size):
    gmap.scatter(coord_lat, coord_lon, 'red', size = m_size , marker = False)
.
.
.

Post a Comment for "Error When Plotting Scatter Plot With Gmplot In Python"