Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

legendgram method #234

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

legendgram method #234

wants to merge 2 commits into from

Conversation

knaaptime
Copy link
Member

for discussion

this moves the legendgram code into a method on the classifier class and tweaks it slightly so it can be used (traditionally) as an inset legend, or put in its own ax. If this is useful, we could probably swap the whole thing for the existing plot_histogram method

@knaaptime knaaptime added enhancement WIP Work in progress. For discussion and feedback. Do not merge. labels Dec 31, 2024
Copy link

codecov bot commented Dec 31, 2024

Codecov Report

Attention: Patch coverage is 11.11111% with 64 lines in your changes missing coverage. Please review.

Project coverage is 84.9%. Comparing base (e2613b5) to head (a421b4b).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
mapclassify/legendgram.py 4.5% 63 Missing ⚠️
mapclassify/classifiers.py 66.7% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #234     +/-   ##
=======================================
- Coverage   89.6%   84.9%   -4.7%     
=======================================
  Files          9      10      +1     
  Lines       1129    1200     +71     
=======================================
+ Hits        1012    1019      +7     
- Misses       117     181     +64     
Files with missing lines Coverage Δ
mapclassify/__init__.py 100.0% <100.0%> (ø)
mapclassify/util.py 93.1% <100.0%> (+0.5%) ⬆️
mapclassify/classifiers.py 88.5% <66.7%> (-0.1%) ⬇️
mapclassify/legendgram.py 4.5% <4.5%> (ø)

@jGaboardi
Copy link
Member

xref pysal/legendgram#21

@martinfleis
Copy link
Member

If this is useful, we could probably swap the whole thing for the existing plot_histogram method

sounds great to me

@knaaptime
Copy link
Member Author

one question (for @ljwolf maybe) is whether we can use bbox_to_anchor in addition to loc kwarg for moving stuff around in the _make_location function. For instance if I have

f, ax = plt.subplots(figsize=(8, 8))
gdf.plot(
    "HH_INC",
    scheme="quantiles",
    k=8,
    ax=ax,
    legend=True,
    legend_kwds={
        "bbox_to_anchor": (
            1.5,
            1,
        )
    },
)
c.plot_legendgram(ax=ax, loc="lower right", legend_size=(0.4, 0.3), inset=True)

it produces this figure, but i'd like to move the histogram beneath the legend using a similar bbox config

download

@martinfleis
Copy link
Member

If we treat legend gram as inset axis and use Axes.inset_axes than you can move the axis in or out as you please, similarly to the placement of legend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement WIP Work in progress. For discussion and feedback. Do not merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants