Giter VIP home page Giter VIP logo

Comments (3)

Casyfill avatar Casyfill commented on June 1, 2024

Hey there. Working on that in #34

from geoplot.

ResidentMario avatar ResidentMario commented on June 1, 2024

As of #114, markerfacecolor and markeredgecolor are now propagated to the legend when you pass color/facecolor and/or edgecolor parameters to your plot.

Sorry to have left this issue open for so long. There are a ton of improvements to geoplot coming out in the next 0.3.0 release, which fixes many many longstanding issues like this and others, you should check it out again once it's done.

from geoplot.

ResidentMario avatar ResidentMario commented on June 1, 2024

Following up to say that this is now addressed more directly by #127.

On geoplot@master you can now pass marker* arguments to legend_kwargs (specifically: {marker, markersize, markeredgecolor, markeredgewidth, markerfacecolor}), and those parameters will be passed to the legend markers.

For example, here is a code snippet demonstrating the current defaults:

import geopandas as gpd
import geoplot as gplt
import geoplot.crs as gcrs

continental_usa_cities = gpd.read_file(gplt.datasets.get_path('usa_cities'))
continental_usa_cities = continental_usa_cities.query('STATE not in ["AK", "HI", "PR"]')
contiguous_usa = gpd.read_file(gplt.datasets.get_path('contiguous_usa'))

ax = gplt.pointplot(
    continental_usa_cities, projection=gcrs.AlbersEqualArea(),
    scale='POP_2010', limits=(2, 30), hue='POP_2010',
    legend=True, legend_var='scale', legend_labels=range(1,6)
)
gplt.polyplot(contiguous_usa, ax=ax)

image

We can fiddle with the legend marker params to get something very different:

import geopandas as gpd
import geoplot as gplt
import geoplot.crs as gcrs

continental_usa_cities = gpd.read_file(gplt.datasets.get_path('usa_cities'))
continental_usa_cities = continental_usa_cities.query('STATE not in ["AK", "HI", "PR"]')
contiguous_usa = gpd.read_file(gplt.datasets.get_path('contiguous_usa'))

ax = gplt.pointplot(
    continental_usa_cities, projection=gcrs.AlbersEqualArea(),
    scale='POP_2010', limits=(2, 30), hue='POP_2010',
    legend=True, legend_var='scale', legend_labels=range(1,6),
    legend_kwargs={
        'markeredgecolor': 'gray',
        'markeredgewidth': 3,
        'markerfacecolor': 'lightgray',
        'marker': '*'
    }
)
gplt.polyplot(contiguous_usa, ax=ax)

Hope that helps. 😄

from geoplot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.