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

Replace GridObject.show with GridObject.plot #142

Merged
merged 2 commits into from
Jan 30, 2025

Conversation

wkearn
Copy link
Contributor

@wkearn wkearn commented Jan 27, 2025

This commit follows the recent change to the StreamObject plotting interface (#130) by adding a plot method to GridObject that plots the object with imshow within the provided axes.

This enables more composable plotting systems and plays nicely with the rest of the matplotlib interface. It can, however, make plotting quite verbose, especially when you need to add a colorbar (see theexcess topography and magicfunctions notebooks for some examples). I considered adding an option to add a colorbar to the plot function, wrapping up all of this axis divider stuff, but there are too many possible options that we would need to expose to make a nice interface.

This behavior was technically already available because GridObject is an array-like object, so it could be passed to imshow directly. This simply makes plotting more obvious. We should probably provide some examples of the array-like interface.

This also resolves #136 by using a logarithmic color scale for the flow accumulation raster.

This commit follows the recent change to the StreamObject plotting
interface (TopoToolbox#130) by adding a `plot` method to GridObject that plots
the object with imshow within the provided axes.

This enables more composable plotting systems and plays nicely with
the rest of the matplotlib interface. It can, however, make plotting
quite verbose, especially when you need to add a colorbar (see
theexcess topography and magicfunctions notebooks for some
examples). I considered adding an option to add a colorbar to the plot
function, wrapping up all of this axis divider stuff, but there are
too many possible options that we would need to expose to make a nice
interface.

This behavior was technically already available because GridObject is
an array-like object, so it could be passed to imshow directly. This
simply makes plotting more obvious. We should probably provide some
examples of the array-like interface.
@wkearn wkearn changed the title Replace show with plot Replace GridObject.show with GridObject.plot Jan 27, 2025
@wkearn wkearn merged commit a13a903 into TopoToolbox:main Jan 30, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better plotting of flow accumulation grids
1 participant