Choropleth map - hide a single country from a map

Hello everyone,

I am trying to create a choropleth map of Europe. I’ve been able to create the map which is colored grey with a white border (landcolor: ‘rgb(229, 229, 229)’, countrycolor: ‘rgb(255, 255, 255)’) and if the data is there, each country is colored depending on the value and the colorscale.

My question is the following: Is it possible to change the default color (when there is no data) of one individual country? Currently, all countries have the same default starting color (landcolor) which is used when there is no data. I would like to blend one country completely away. Is it possible to use a different color for that particular country, i.e. using landcolor: ‘rgb(255, 255, 255)’ would practically make it invisible in my case. Or any other way to blend a specific country away?


Not at the moment.

I’d recommend plotting a second choropleth trace with a degenerate colorscale e.g.:

   locations: [/* countries with no data */],
   z: [0,0,0, ...],
   colorscale: [[0, 'red'], [1, 'red']]

to get this effect.

Hi Etienne!

Thanks a lot for this great tip!
I was able to almost achieve the effect I want. The country I want to remove is now appearing white.

The line should also be white:

marker: {
color: ‘rgb(255,255,255)’,
width: 0,

But I still get some kind of line around the country shape which I am not able to remove. Please see the attached images without and with contrast enhancement.

Do you have an idea how to remove that line?

Maybe try setting layout.geo.showcountries: false and/or layout.geo.showcoastlines

Tried. But was not able to get rid of that line with any combination of settings.
But thanks for the tip Etienne!

I used “marker” parameter to change the country border width and color:

data = [go.Choropleth(
locations = plot_data[‘CODE’],
z = plot_data[‘2018’],
text = plot_data[‘Country’],
colorscale = orange,
autocolorscale = False,
reversescale = True,
marker = go.choropleth.Marker(
line = go.choropleth.marker.Line(
color = ‘rgb(255,255,255)’,
width = 0.5
colorbar = go.choropleth.ColorBar(
tickprefix = ‘’,
title = ‘rate’),