Skip to content

feat: Add plot_params to allow custom figsize (#68)#69

Open
alexbthundiyil-spec wants to merge 3 commits intoRussellSB:developfrom
alexbthundiyil-spec:feature/issue-68-figsize
Open

feat: Add plot_params to allow custom figsize (#68)#69
alexbthundiyil-spec wants to merge 3 commits intoRussellSB:developfrom
alexbthundiyil-spec:feature/issue-68-figsize

Conversation

@alexbthundiyil-spec
Copy link
Copy Markdown

Fixes #68 by mapping a plot_params argument to the internal matplotlib subplots.

@RussellSB
Copy link
Copy Markdown
Owner

RussellSB commented Mar 29, 2026

Hey @alexbthundiyil-spec ! Thanks for the PR! For completeness, would you mind adding a new module under tests/test_plotting/custom to reflect this? Can add a simple test that the image changes in figsize (and/or title) as its supposed to. I use pytest-mpl to be able to test figure related features. You can reference the other modules in the tests/test_plotting folder for examples.

P.S. I have also made minor edits to the docstring to resolve a merge conflict, and align with a slightly new format I've tested looks nicer on the recently deployed docs site.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@alexbthundiyil-spec
Copy link
Copy Markdown
Author

I've gone ahead and added the requested pytest-mpl module under tests/test_plotting/custom/test_custom_plot_params.py. It generates a baseline image testing the custom figsize and title parameters properly. Let me know if that works!

Copy link
Copy Markdown
Owner

@RussellSB RussellSB left a comment

Choose a reason for hiding this comment

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

Thank you very much for adding a test! I've had a look and added some comments. At the moment title doesn't update since it cant be passed through 'plt.subplots()'.

Can either:

  1. Add a workaround to handle the non subplot properties
  2. Limit this PR to focus on figsize as a foundation, and address nitpicking comments to make this more clear

I'm happy with either.


plot_params = {
'figsize': (16, 8),
'title': "Custom Plot Title"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can remove title it turns out, it can't be passed to subplots().

- **is_abrupt_padded** (`bool`): Whether to pad abrupt transitions between segments. Defaults to `False`.
- **abrupt_padding** (`int`): Number of days to pad around abrupt transitions. Only referenced when `is_abrupt_padded` is `True`. Defaults to `28`.
plot_params (dict, optional):
Dictionary of plotting parameters to pass to `plot_pytrendy`. Supported keys:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Specify in comment to pass to plt.subplots() in plot_pytrendy. In case user is interested in trying other args as long as it's applicable to subplots call.

Comment on lines 150 to 152
ax.set_title("PyTrendy Detection", fontsize=20)
ax.set_xlabel("Date")
ax.set_ylabel("Value")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Title related properties would need to be passed here rather than subplots.

I think it could be useful to make this customisable alongside figsize, however they would need to be identified and passed into here.

Up to you. Following other comments, I'm also fine if we just limit this PR to figsize as a foundation, then can build onto it with other PRs.

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.

[Enhancement] Make plot pytrendy customisable

2 participants