1

I need to plot poly-lines from a geopandas file, where every line has its own color based on same value (see plot). I am using this script for plotting:

line = geopandas.read_file(shapefile.shp)
ax = plt.subplots()
for i in range(0,3):
      line.loc[[i],'geometry'].plot( ax = ax )

enter image description here

Do you know how to color every line based on its relative value and add a colormap legend on the side?

Thank you!!

1 Answer 1

1

I have a column named objekttypn which I want to use as categories:

import geopandas as gpd
df = gpd.read_file(r"C:/Users/bera/Desktop/gistest/roads_260.shp")

ax = df.plot(column="objekttypn", cmap="tab20", legend=True, 
categorical=True, figsize=(10,10))

enter image description here

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.