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

Adds plotting methods #115

Merged
merged 21 commits into from
Dec 1, 2023
Merged

Adds plotting methods #115

merged 21 commits into from
Dec 1, 2023

Conversation

BradyPlanden
Copy link
Member

@BradyPlanden BradyPlanden commented Nov 21, 2023

This PR completes the following:

  • Adds a cost landscape (plot_cost2D) method
  • Default time-series plotting method for comparing
    • Dataset
    • Synthetic model with identified parameters
    • Slider functionality updating the fit for each optimisation step
  • Optimiser convergence plot method
  • Parameter value per iteration plot method

Update:
I've left the slider off this PR as future functionality to add. Additionally, the above plots work across all optimisers, except plot_parameters() and plot_convergance() which don't currently support NLopt and SciPy optimisers.

@BradyPlanden BradyPlanden linked an issue Nov 21, 2023 that may be closed by this pull request
Copy link

codecov bot commented Nov 21, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (5225cfc) 90.57% compared to head (1e505ee) 92.65%.

Files Patch % Lines
pybop/plotting/plotly_manager.py 75.47% 13 Missing ⚠️
pybop/optimisers/base_optimiser.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #115      +/-   ##
===========================================
+ Coverage    90.57%   92.65%   +2.07%     
===========================================
  Files           18       30      +12     
  Lines          647     1007     +360     
===========================================
+ Hits           586      933     +347     
- Misses          61       74      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BradyPlanden
Copy link
Member Author

This should now be ready for review. Four methods have been added:

  1. pybop.plot_2d(cost, optim=optim, steps=10) which has an optional argument to overlay the optimiser evolution on the contour and # of steps.
  2. pybop.plot_convergence(cost) plots the minimum cost value at each iteration of the optimisation.
  3. pybop.plot_parameters(cost) create sub-plots for the evolution of the parameter values during the optimisation.
  4. pybop.quick_plot(cost) creates a voltage against time figure for the identified parameters and the target data set.

plot_convergence() and quick_plot() both use the added StandardPlot class for figure creation. This class provide a standard figure implementation for single plot figures, this addition provides a base class for future figure expansion/additions.

All the plotting is completed using plotly, with the setup.py updated to have an optional installation of pip install pybop[plots] or pip install pybop[all].

See updated initial comment on functionality with nlopt and scipy.

Here are some sample figures, generated from the spm_adam.py example. First, quick_plot():

newplot(1)

plot_convergence():

newplot(2)

plot_parameters():

newplot(3)

plot_2d() without optimiser evolution:

newplot(4)

and with (where the red marker is the starting position):

newplot(5)

Copy link
Member

@NicolaCourtier NicolaCourtier left a comment

Choose a reason for hiding this comment

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

Nice work on these plotting scripts, thanks @BradyPlanden! The plots are clear and useful - a great addition to PyBOP.

@BradyPlanden BradyPlanden merged commit 96b1ffb into develop Dec 1, 2023
19 checks passed
@BradyPlanden BradyPlanden deleted the 114-plotting-classes branch December 1, 2023 14:44
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.

Plotting classes
2 participants