Skip to content

KDE plot and various tweaks. #307

Open
Averydx wants to merge 7 commits into
2.0-betafrom
KDE
Open

KDE plot and various tweaks. #307
Averydx wants to merge 7 commits into
2.0-betafrom
KDE

Conversation

@Averydx

@Averydx Averydx commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

This branch contains the KDE plot and tweaks allowing the user to choose whether to cycle the kwargs over the geo or quantity. The notebooks plotting_example.ipynb and pf_v_enkf.ipynb show a number of examples of plots in action.
Note these notebooks need to be removed before merge commit.

…gs cycle over the geos or the quantities in *_plt functions. The notebooks plotting_example.ipynb and pf_v_enkf.ipynb contain a number of examples. Note these notebooks should be removed before final merge.
@Averydx
Averydx requested a review from JeffreyCovington July 6, 2026 01:35

@JeffreyCovington JeffreyCovington left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See comments.

Comment thread epymorph/forecasting/filter_plot.py Outdated
Comment thread epymorph/forecasting/filter_plot.py Outdated
Comment thread epymorph/forecasting/filter_plot.py Outdated
Comment thread epymorph/forecasting/filter_plot.py Outdated
Comment thread epymorph/forecasting/filter_plot.py
@Averydx

Averydx commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

I noticed some issues with the way I was deleting yticks from unused subplots. If sharey = True this deletes the global yticks from the plot. Also, we could just delete unused subplots but if sharex = True and the unused plots are in the last row then labels for a column will be omitted.

@Averydx

Averydx commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

The notebooks for testing various plots are linked below.

plotting_example.ipynb
pf_v_enkf.ipynb

@Averydx Averydx self-assigned this Jul 10, 2026
@Averydx Averydx added the enhancement New feature or request label Jul 10, 2026
Comment on lines +315 to +317
kwarg_type :
Whether to iterate the kwargs over the quantities or the geos.
Options are "geo", default is quantity iteration.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When a parameter accepts a small set of string literals, we should type it narrowly than str. In this case: Literal["quantity", "geo"]. You can make that a named type if that helps readability.

For the sake of consistent docs, I'd prefer to use a bullet list containing all of the options.

The legend parameter from plot.line() is an example of both of the above.

Comment on lines +318 to +320
ax_title :
A format string to display as the title for each subplot.
Defaults to displaying the geo.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know this feels redundant, but this doc string (and any others that use format strings) should be explicit about which replacement variables are supported. Again, refer to plot.line().

Comment on lines 183 to 186
"auto" will use the format defined by the grouping of the `time` parameter,
"date" attempts to display calendar dates,
"day" attempts to display days numerically indexed from the start of the
simulation with the first day being 0.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This also needs bullet-list markup.

Comment on lines +437 to +439
if leg is not None:
for lh in leg.legend_handles:
lh.set_alpha(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a reason to wait to modify the legend down here, or can we move this block up closer to where leg was declared?

Also, Pylance is telling me the legend handles list can contain None. This is probably just matplotlib being sloppy with types, but should probably do one more if-check for safety.

Comment on lines +548 to +559
geo_indices = np.array(geo.indices)

if geo.grouping is None:
if geo.aggregation is None:
num_nodes = self.output.rume.scope.nodes
else:
num_nodes = 1

else:
num_nodes = len(
np.unique(geo.grouping.map(geo.scope.node_ids[geo_indices]))
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This logic occurs four times. Good candidate to move to a helper function?

@JavadocMD JavadocMD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Whoops, I forgot to "start review" with the above comments, but see above comments. I think some of the guidance on docstring style should be applied broadly across the different plot functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants