778 questions
72
votes
2
answers
60k
views
How do I change the NA color from gray to white in a ggplot choropleth map?
I am trying to create a choropleth map of the US that has the default color changed from gray to white.
I have records for 18 of 48 states and the code works to color by value, but for those states ...
52
votes
1
answer
10k
views
Choropleth map using folium and pandas
I am using folium to create a choropleth map of a set of countries. I am following the documentation. However. for some reason the map doesn't show any shades. I am using the world geojson from ...
32
votes
3
answers
28k
views
Error: isTRUE(gpclibPermitStatus()) is not TRUE
This question may be a duplicate of an earlier unanswered one. I still have the problem.
I am trying to use a zipcode shapefile and coming up with the following error:
tract <- readOGR(dsn = ".", ...
30
votes
1
answer
37k
views
How do I set each plotly subplot title during graph creation loop?
I understand that if I want to set all of the subplot titles then I can do that when I declare the figure.
import pandas as pd
import plotly.graph_objs as go
from plotly.subplots import make_subplots
...
19
votes
1
answer
17k
views
Making a zip code choropleth in R using ggplot2 and ggmap
I am trying to make a choropleth of very simple data, and it's kind of a pain in the neck. I have the following zip codes in the Eastern USA. This is made up data but you get the idea.
Zip Freq
...
16
votes
2
answers
52k
views
Adjust the size of the text label in Plotly
I'm trying to adjust the text size according to country size, so the text will be inside the boarders of the country. Here's my code:
# imports
import pandas as pd
import plotly.express as px
# ...
16
votes
3
answers
10k
views
Python: how to create a choropleth map out of a shapefile of Canada?
My goal here is to create a choropleth map of Canada in Python. Suppose I have a dictionary with values referring to each Canadian province/territory:
myvalues={'Alberta': 1.0,
'British Columbia': 2....
16
votes
1
answer
3k
views
Optimising Shiny + Leaflet performance for detailed maps with many 'layers'
I want to make a Shiny app where the colouring of a choropleth is based on a numeric value of one of many possible quantitative variables that a user can select from. In simple cases, this is ...
15
votes
4
answers
29k
views
Plot map with values for countries as color in R?
I have following simple example data which I want to plot on a map with gradient color corresponding to value of the given country.
ddf = read.table(text="
country value
USA 10
UK 30
Sweden 50
Japan ...
14
votes
2
answers
36k
views
List of locationmode to use with plotly
I need to make a graphical representation of data distributed in Brazil, which is my country.
I found that plotly can do this job, but when I went to research how to use plotly, every tutorial was ...
13
votes
2
answers
1k
views
Drilldown in highmaps - how to remove a series
I am currently trying to create a drilldown map on Highmaps using this example:
http://www.highcharts.com/maps/demo/map-drilldown
I have got this to work with my own data for a different country ...
11
votes
2
answers
13k
views
ggplot - Create a border overlay on top of map
So I am trying to create a Florida county-level map with borders based on a custom variable. I included an older version of the map that I am trying to create here
Essentially, the map shows a ...
11
votes
2
answers
7k
views
Choropleth maps for Germany
I am having Revenue data which I need to map on the German map.
My data contains the postcodes, the corresponding latitude and longitude, as well as the value of revenue corresponding to that ...
10
votes
2
answers
14k
views
Text as tooltip, popup or labels in folium choropleth GeoJSON polygons
Folium allow to create Markers with tooltip or popup text. I would like to do the same with my GeoJSON polygons.
My GeoJSON has a property called "name" (feature.properties.name -> let's ...
10
votes
1
answer
12k
views
Edit labels in tooltip for plotly maps using ggplot2 in r
I know this question has been asked a number of times but I think some of the underlying syntax for plotly has changed since those questions have been asked. Using ggplotly() to create a choropleth ...
9
votes
3
answers
8k
views
reverse colors in colorNumeric()
I am trying to reverse the colors of a choropleth map. I am using the leaflet package and the colorNumeric() function, here is the code that generates the palette function:
pal <- colorNumeric(...
9
votes
1
answer
10k
views
Plotly: Australia Choropleth map
I am having a list of states and territories of Australia with their corresponding values. Now I want to produce a heat map like this:
I am following the examples with Pyplot from this link but it ...
9
votes
2
answers
3k
views
Overlay multiple riverplots (Sankey diagrams) on a map of the world
The fascinating chart below is in the Economist, Jan. 30, 2016 at 61. It depicts exports of liquified natural gas (LNG) from five regions to six regions. How can R draw something similar to it, ...
8
votes
1
answer
8k
views
How to apply different border widths for subregions in python geopandas choropleth map
I am making choropleth maps with geopandas. I want to draw maps with two layers of borders: thinner ones for national states (geopandas default), and thicker ones for various economic communities. Is ...
7
votes
1
answer
11k
views
Increasing speed on plotly animation
I created a choropleth map using plotly express's function choropleth() Code is below.
fig = px.choropleth(df_countrydate,
locations="Country",
locationmode = ...
7
votes
1
answer
5k
views
Dropdown menu for Plotly Choropleth Map Plots
I am trying to create choropleth maps. Below is an example that works:
df = px.data.gapminder().query("year==2007")
fig = go.Figure(data=go.Choropleth(
locations=happy['iso'], # Spatial ...
7
votes
1
answer
2k
views
Alaska and Hawaii not formatting correctly for County Choropleth Map in R
I am trying to format a Choropleth Map of the United States to a specific color and unfortunately, when using scale_fill_brewer to change the color; only 48 of the states do (Hawaii and Alaska do not)....
7
votes
2
answers
4k
views
How to disable zoom in plotly choropleth mapbox plot with Python?
Here is my code:
fig = px.choropleth_mapbox(district_df[['District','Confirmed','Deaths','id','province']], geojson = geo_df, locations='id', color='Confirmed',
...
7
votes
1
answer
2k
views
Combining choropleth made in ggplot and ggmap
Created a choropleth using ggplot2. Here's the ggplot code
okc <- ggplot() +
geom_polygon(data = mapdata, aes(x = long, y = lat, group = group,
fill = ...
7
votes
0
answers
1k
views
How to speed up a Python Basemap choropleth animation
Taking ideas from various sources, and combining with my own, I sought to create an animated maps showing the shading of countries based on some value in my data.
The basic process is this:
Run DB ...
6
votes
1
answer
5k
views
Change text/labels ggplot legend
I believe this question is slightly different than similar ones asked on here before because of the use of scale_fill_brewer(. I'm working on a choropleth similar to this one https://gist.github.com/...
6
votes
1
answer
12k
views
FeatureGroup layer control in Folium - only one active layer
I am trying to display several layers with information on a Choropleth Map having as base layer the Stamen Terrain and displaying the layers as FeatureGroup.
Here is my initial code without overlay ...
6
votes
3
answers
609
views
Callback to subset geometry data - dash Plotly
I'm hoping to include a dropdown bar with a callback function that allows the user to display specific points within smaller areas. Initially, I want to use all point geometry data as a default. I'm ...
6
votes
1
answer
4k
views
Plotly Choropleth combined with ScatterGeo
Can anyone help me spot the error here?
fig = go.Figure()
fig.add_trace(
go.Choroplethmapbox(
geojson=counties,
locations=df_se['FIPS'], z=df_se['use_values'],
colorscale=...
6
votes
1
answer
2k
views
Changing the attributes of the what appears when hovering over a Choropleth Map in plotly
I am using plotly in Python 3.6.3 and am trying to do a Choropleth map as in here. I would like to change the attributes of what appears when hovering above the map. That is, for example, if we ...
6
votes
0
answers
612
views
How to add a colorbar to a thematic map plot in Julia?
I would like to add a gradient (vertical) colorbar to my thematic map plot in Julia with values from the variable values. The map below is a population density choropleth.
Any suggestions how to add a ...
5
votes
3
answers
7k
views
Plot 2 tmap objects side-by-side
Example:
I want to plot two tmap plots side by side, which are generated by this code.
library(tmap)
library(gridExtra)
data(World)
plot1=
tm_shape(World, projection = "merc") +
tm_layout("", ...
5
votes
3
answers
8k
views
Plotting a choropleth map (with geopandas) using a user_defined classification scheme
I'm kind of new to python, so I'm hoping that the answer to my question is relatively straight forward.
I'm trying to make a choropleth map using geopandas. However, since I'm making multiple maps ...
5
votes
1
answer
7k
views
Plotly Express Choropleth for Country Regions
I have a dataframe created on a csv file about Italian Covid-19 spread all over regions. I was trying to create a px.choropleth plot in which showing Total Positive values for every regions in Italy.
...
5
votes
3
answers
10k
views
Editing Colorbar (Legend) in Geopandas?
There are multiple thing I want to edit with the colorbar in a geopandas world choropleth I'm creating. Namely the size (so that it roughly matches the map itself), the text size (which currently ...
5
votes
2
answers
15k
views
Mapbox GL JS Creating Custom Legend
I have created a custom map in Mapbox Studio with a tileset to create a choropleth map I have then exported the map, to extend the map using Mapbox GL JS.
I have followed the tutorial for creating a ...
5
votes
2
answers
12k
views
Generating spatial heat map via ggmap in R based on a value
I'd like to generate a choropleth map using the following data points:
Longitude
Latitude
Price
Here is the dataset - https://www.dropbox.com/s/0s05cl34bko7ggm/sample_data.csv?dl=0.
I would like ...
5
votes
1
answer
13k
views
Creating Choropleth map in plotly with latitude and longitude
I wanted to know if it is possible to create a choropleth map using plotly in python with latitude and longitude as locations. What would be the locationmode in this case?
5
votes
1
answer
12k
views
Plotting UK Districts, Postcode Areas and Regions
I am wondering if we can do similar choropleth as below with UK District, Postcode Area and Region map.
It would be great if you could show an example for UK choropleths.
Geographic shape files can ...
5
votes
2
answers
4k
views
Folium Choropleth + GeoJSON raises AttributeError: 'NoneType'
I'm trying to do a choropleth using folium which offers a great link between GeoJSON, Pandas and leaflet.
GeoJSON format is like below :
{
"type":"FeatureCollection",
"features":[
{
...
5
votes
1
answer
1k
views
geom_map "map_id" reference issue
I am trying to create a choropleth map of US counties with two datasets connected by FIPS codes. I am using the maps package county and county.fips data, combined into one data.table like this (...
5
votes
1
answer
2k
views
Nonlinear colormap in a folium map
I'm drawing colored regions on a folium map using log scale shading. Using custom colormap, the region colors seem to be ok. But the colormap, when added to the map legend, still looks linear:
Is ...
5
votes
3
answers
3k
views
Choropleth map with OpenStreetMap data
My goal is to get a so-called "choropleth map" (I guess) of the zip code areas in Germany. I have found the python package "folium" but it seems like it takes a .json file as input:...
4
votes
1
answer
23k
views
Python - Folium Choropleth Map - colors incorrect
My problem is that suburbs are not displaying the correct color on the Folium map. For example, Dandenong and Frankston should be shaded with the darkest color as they have the highest count in the ...
4
votes
2
answers
13k
views
dcc.Loading on First Load Only (Python)
I am working on a Plotly Dash project that has a lot of choropleth maps that are filtered, sliced, and diced. These are pretty expensive computations that slow everything down, so I thought as a nice ...
4
votes
1
answer
7k
views
plotly choropleth map: display country names
Consider the following R code to produce a choropleth map in plotly:
#devtools::install_github("ropensci/plotly")
library(plotly)
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/...
4
votes
1
answer
2k
views
Altair choropleth map, color highlight based on line chart selection
I am plotting a choropleth map colored by the field Passenger_0_ and a line chart showing the evolution of Passenger_0_ throughout a day by zone.
I would like to select a line (zone) in the line chart ...
4
votes
1
answer
7k
views
plotly express choropleth map customizing hover data error: ValueError: Value of 'hover_data_0' is not the name of a column in 'data_frame'
I tried to create an interactive choropleth plot of COVID-19 Confirmed Cases by US State using plotly.express.choropleth, but I encountered an issue as I was trying to customize the hover_data. Here ...
4
votes
3
answers
2k
views
How to plot a specific column from a SpatialPolygonDataframe with leafletR?
I would like to create a choropleth map using leafletR::leaflet.
My data comes in a SpatialPolygonsDataFrame, and I would like to choose a specific column to be plotted.
With sp::spplot, this is easy-...
4
votes
1
answer
2k
views
Filtering to State Level for Choropleth Maps in Altair
I've been playing around with Altair's map functionality. I'm very easily able to build US maps with state and county boundaries now. What I'm stuck on is filtering the maps down to a lower level. For ...