Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom tick marks for colormap

How can I determine which numbers I would like to display on a colormap?

E.g. GeoPandas automatically displays 0.2*10^9, 0.4*10^9, 0.6*10^9 ... and so on. What if I just want to display 0, 500,000,000 and1,000,000,000 at the correct position?

import geopandas as gpd

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot(column='pop_est', legend=True)

enter image description here

like image 306
Stücke Avatar asked Jan 28 '26 02:01

Stücke


1 Answers

You can use the parameter legend_kwds and pass the desired ticks as a list.

import matplotlib.pyplot as plt
import geopandas as gpd

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot(
    column='pop_est', 
    legend=True,
    legend_kwds={'ticks': [0,500000000,1000000000]}
)
plt.show()

enter image description here

like image 159
Derek O Avatar answered Jan 29 '26 14:01

Derek O