import pandas as pd
import geopandas as gpd
import plotnine as p9
df = pd.DataFrame({"x": [0, 1, 2], "y": [2, 1, 0], "group": ["A", "B", "A"]})
geo_df = gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df.x, df.y))
# Create a plot using geom_map
(
p9.ggplot(geo_df)
+ p9.geom_map(p9.aes(fill="group"), size=4, stroke=0.5, shape="v")
+ p9.labs(title="Plotted by geom_map")
)
# Create a plot using geom_point (for comparison)
(
p9.ggplot(df)
+ p9.geom_point(p9.aes(x="x", y="y", fill="group"), size=4, stroke=0.5, shape="v")
+ p9.labs(title="Plotted by geom_point")
)
When using
geom_mapto plot points on a map, the figure panel itself looks perfectly correct. However, the legend seems to mistake thesizewith thestrokeargument. Also, the legend always uses squares for the shape, no matter what value is passed to theshapeargumentHere is an example: