porespy icon indicating copy to clipboard operation
porespy copied to clipboard

Visualization functions should optionally accept `ax` as argument

Open ma-sadeghi opened this issue 1 year ago • 2 comments

(for more granular control)

ma-sadeghi avatar Jun 23 '23 00:06 ma-sadeghi

sem and xray current accept axis. Are you suggesting it would be more convenient to shorten it? Or are you suggesting this argument should be added to other functions? As for the former, I think ax implies that you're passing in a mpl axis object, since fig, ax = plt.subplots() is now pretty universally used. If the latter, which ones did you have in mind?

jgostick avatar Mar 10 '24 17:03 jgostick

Yeah, I meant an mpl axis. Specifically, I'm proposing that all visualization functions accept an optional argument ax, which if not given will be created internally, and return the ax object rather than the figure object. I've seen this pattern in many places (arviz for example).

The benefit is that you have more control, e.g., you can resize the figure: fig, ax = plt.subplots(figsize=...), or maybe you want to overlay some other stuff on the same axis, or maybe you have a multi-row/column figure and you want a particular entry to be painted by the function, etc.

You can do all this using the current approach too, it's just extra typing.

ma-sadeghi avatar Mar 10 '24 22:03 ma-sadeghi