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

BUG: colorbar did not match normalised colors #1089

Merged
merged 8 commits into from Sep 21, 2019

Conversation

martinfleis
Copy link
Member

@martinfleis martinfleis commented Aug 11, 2019

In current version, if you use normalisation, colorbar does not represent true color scheme as it is always normalized linear between min and max. This PR fixes the behaviour and normalises colorbar using the same scheme, so the results should match.

It should resolve issue like #697 (comment) .

gdf = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
gdf['random'] = np.random.gamma(2, 2, len(gdf)) - 2

vmin, vmax, vcenter = gdf.random.min(), gdf.random.max(), 0
divnorm = colors.DivergingNorm(vmin=vmin, vcenter=vcenter, vmax=vmax)

gdf.plot(column='random', cmap='RdBu', legend=True, norm=divnorm)

Before:
before
After:
after

Closes #697

@codecov
Copy link

codecov bot commented Aug 11, 2019

Codecov Report

Merging #1089 into master will decrease coverage by 1.94%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1089      +/-   ##
==========================================
- Coverage    90.2%   88.25%   -1.95%     
==========================================
  Files          19       19              
  Lines        1837     1839       +2     
==========================================
- Hits         1657     1623      -34     
- Misses        180      216      +36
Impacted Files Coverage Δ
geopandas/plotting.py 92.5% <100%> (-0.78%) ⬇️
geopandas/tools/crs.py 48.14% <0%> (-37.04%) ⬇️
geopandas/io/file.py 80% <0%> (-14.74%) ⬇️
geopandas/io/sql.py 82.14% <0%> (-14.29%) ⬇️
geopandas/_compat.py 85.71% <0%> (-14.29%) ⬇️
geopandas/geodataframe.py 97.11% <0%> (-0.83%) ⬇️
geopandas/geoseries.py 96.91% <0%> (-0.62%) ⬇️
geopandas/array.py 94.07% <0%> (-0.52%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c42164...24b08a0. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 11, 2019

Codecov Report

Merging #1089 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1089      +/-   ##
==========================================
+ Coverage   89.67%   89.71%   +0.03%     
==========================================
  Files          20       20              
  Lines        1967     1973       +6     
==========================================
+ Hits         1764     1770       +6     
  Misses        203      203
Impacted Files Coverage Δ
geopandas/plotting.py 92.15% <100%> (+0.06%) ⬆️
geopandas/array.py 93.55% <0%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6b835c...a270293. Read the comment docs.

@martinfleis
Copy link
Member Author

Probably resolves #393, but that issue is super unclear.

@jorisvandenbossche
Copy link
Member

Fixed the conflict after merging the other PR

@jorisvandenbossche
Copy link
Member

This is giving some errors. It might be that the test needs to be updated now the other PR is merged.

@martinfleis
Copy link
Member Author

Tests should be fixed now. I'll wait for CI and merge.

@martinfleis martinfleis merged commit 8903e75 into geopandas:master Sep 21, 2019
@martinfleis martinfleis deleted the cbar branch September 21, 2019 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass keywords to colorbar construction
2 participants