-
Notifications
You must be signed in to change notification settings - Fork 159
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
Vector colorbar compatibility #572
base: main
Are you sure you want to change the base?
Conversation
updating earthpy
Updating from EarthPy master
Updating from earthpy repo
Updating from master
Updating from master
Fixed the last two vignettes so that their thumbnails work. (earthlab#407)
Updating!
Updating from master
Updating from master
Updating!
updating from master
Modis data clarification and CI fixes (earthlab#497)
Update sphinx_gallery from 0.5.0 to 0.6.2 (earthlab#531)
@lwasser this pr is failing CI because I'm using |
hey @ravi5175 just checking in. did you review this PR or are you just practicing your skills? generally PRs are reviewed by maintainers on OS projects. |
closes #557
Updated the
ep.colorbar
function to work with GeoDataFrame plots. This was a bit tricky, and I'm not sure this is the exact way we want to implement this, so feedback would be greatly appreciated @lwasser .There are two ways I've figured out to make this work, but neither of them is ideal, so I thought I'd ask for input. I went with what I thought was the simpler way, but wasn't sure if there was a better way.
The way GeoPandas does colorbars is just by setting
legend=True
in theplot()
function. To adjust the colorbar, you can give it acax
argument, which will implement thescale
andpad
arguments we have in ourep.colorbar()
function.In the
ep.colorbar()
function, we create a cax object and assign it to the figure. The problem is, this assumes that the object that was passed into theep.colorbar()
is what matplotlib calls aScalarMappable
, so like an array or a contour map is aScalarMappable
. A GeoDataFrame is not inheritely aScalarMappable
like numpy arrays are, so we can do one of two things. We can either make the function have an argument to return the cax before it's applied to the figure and then that can be used ingpd.plot()
, which is what I did.The other way would be to create a
ScalarMappable
in the function for the plot. This needs a cmap and a norm object for the map. That seemed like a lot of information to get/create in the function, so I avoided this solution.The return cax option does change how the function is implemented a little. See below for how it changes implementation.