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

Add "at" keyword for imshow and other enhancements #1430

Merged
merged 11 commits into from
May 25, 2022

Conversation

mcflugen
Copy link
Member

This pull request addresses #1424 but adding an at keyword to imshow when used as a ModelGrid method. There are also a couple other changes:

  • imshow is now available to all ModelGrids
  • imshow can now guess at a location to plot values if the at keyword is not given. This allows things like: grid.imshow(values) and grid.imshow("topographic__elevation").
  • deprecates the values_at keyword
  • deprecates usages like imshow("node", "topographic__elevation")

@mcflugen
Copy link
Member Author

@vaga3461, @ethan-pierce: I noticed you used the imshow_grid function a lot in your landlab clinic. Would one of you have time to give this pull request a look over and let me know what you think of the changes?

I added an imshow method to all of the grids (raster, hex, radial, etc.) so that you don't have to import imshow_grid anymore. So instead of,

from landlab.plot import imshow_grid
imshow_grid(grid, ...)

you can just do,

grid.imshow(...)

I've also made the syntax (I think) a little cleaner and more like other parts of landlab. Instead of,

imshow_grid(grid, "node", "topographic__elevation")

you can do,

grid.imshow("topographic__elevation", at="node")

If you don't provide an at location, imshow_grid will guess at a location.

grid.imshow(values)  # values is a array of values, doesn't have to be a field
grid.imshow("topographic__elevation"). # looks for the named field first at nodes, and then at cells

vaga3461
vaga3461 previously approved these changes May 24, 2022
Copy link
Contributor

@vaga3461 vaga3461 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes look good to me, I like that you've made the syntax more similar to other functions. Thanks!

@mcflugen
Copy link
Member Author

Thanks @vaga3461! I'll update the usages of imshow_grid in the notebooks and then merge.

@mcflugen mcflugen merged commit 9ec0cbe into master May 25, 2022
@mcflugen mcflugen deleted the mcflugen/at-keyword-for-imshow branch May 25, 2022 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants