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

Add bokeh plots and deprecate contributions_pie #715

Merged
merged 9 commits into from Apr 4, 2024
Merged

Conversation

raoulcollenteur
Copy link
Member

@raoulcollenteur raoulcollenteur commented Apr 2, 2024

Short Description

This PR adds basic plotting using Bokeh to Pastas models. To use this, bokeh plots needs to be registered as an extension, as implemented by @dbrakenhoff for plotly. I started with two basic plots, but this can grow over time.

I also added the deprecation for contributions_pie.

Checklist before PR can be merged:

Copy link

codacy-production bot commented Apr 2, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.16% (target: +0.00%) 60.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c7b2b58) 6114 4625 75.65%
Head commit (0fb6ce1) 6130 (+16) 4647 (+22) 75.81% (+0.16%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#715) 5 3 60.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

@raoulcollenteur
Copy link
Member Author

@dbrakenhoff shall I extend the plotly notebook example and add bokeh there as well, and rename to interactive_plots.ipynb?

@raoulcollenteur
Copy link
Member Author

@dbrakenhoff this PR is ready for Review. But perhaps you can have a quick look at the Plotly plots in the notebook, somehow they don't show up on my system?

Cheers,
Raoul

@raoulcollenteur raoulcollenteur changed the title Add bokeh plots Add bokeh plots and deprecate contributions_pie Apr 3, 2024
@dbrakenhoff
Copy link
Member

@raoulcollenteur, both are working for me in jupyter lab. Which versions are you on? For me. the following worked:

  • plotly 5.16.1
  • bokeh 3.4.0
  • jupyter lab 4.1.1

FYI, there seems to be some funkiness going on in the bokeh plots:
image

And a note for anyone trying to view the bokeh plots in a VS Code notebook environment, the interactive figures don't show up.
bokeh/bokeh#10765

Copy link
Member

@dbrakenhoff dbrakenhoff left a comment

Choose a reason for hiding this comment

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

See earlier comment about the funkiness in Bokeh plot. Otherwise looking good!

Setting up somewhat complicated shared axes seems a lot easier in bokeh than in plotly (not having to dive down into the low-level API). And I'm a fan of the range slider at the bottom :). Maybe we can just leave the background of that plot white, so the selected range (also gray) is clearer.

@raoulcollenteur
Copy link
Member Author

@raoulcollenteur, both are working for me in jupyter lab. Which versions are you on? For me. the following worked:

  • plotly 5.16.1
  • bokeh 3.4.0
  • jupyter lab 4.1.1

FYI, there seems to be some funkiness going on in the bokeh plots: image

And a note for anyone trying to view the bokeh plots in a VS Code notebook environment, the interactive figures don't show up. bokeh/bokeh#10765

Hmm, interesting... Was this in VS code or JupyterLab? Do you have bokeh-jupyter-bokeh extension installed in JupyterLab? Perhaps that is necessary?

@dbrakenhoff
Copy link
Member

Was this in VS code or JupyterLab? Do you have bokeh-jupyter-bokeh extension installed in JupyterLab? Perhaps that is necessary?

This was in JupyterLab. Both without and with the bokeh-jupyter-bokeh jupyterlab extension installed.
VS code does not render Bokeh plots unfortunately.

I think the data isn't sorted properly when I run ml.get_output_series():

image

@raoulcollenteur
Copy link
Member Author

Hmm, so the problem is not in bokeh plots. If I run the code above my data is well ordered.

Python version: 3.11.3
NumPy version: 1.24.4
Pandas version: 2.1.4
SciPy version: 1.12.0
Matplotlib version: None
Numba version: 0.59.0
LMfit version: 1.2.2
Latexify version: Not Installed
Pastas version: 1.5.0b

Is this a new Pandas problem?!

@dbrakenhoff
Copy link
Member

That could well be it, pandas 2.2 here.

Copy link

codacy-production bot commented Apr 3, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.06% (target: +0.00%) 66.67%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c7b2b58) 6114 4625 75.65%
Head commit (efe9f9a) 6137 (+23) 4646 (+21) 75.70% (+0.06%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#715) 6 4 66.67%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

@raoulcollenteur
Copy link
Member Author

I think it is related to this issue: pandas-dev/pandas#57006

Probably good to fix in ml.get_out_series anyway.. Could you check if adding sort=True in pd.concat fixes the problem?

@dbrakenhoff
Copy link
Member

Yep, that fixes it! Committed the change. Is it still working on your end?

@raoulcollenteur
Copy link
Member Author

Yes all good here! I'll go through the changes in 2.2 again to see if more might be up. Should we merge this PR now?

@raoulcollenteur raoulcollenteur requested review from dbrakenhoff and removed request for martinvonk April 4, 2024 06:38
@raoulcollenteur
Copy link
Member Author

I updated the docs (https://pastas--715.org.readthedocs.build/en/715/api/generated/generated/generated/pastas.plotting.bokeh.Bokeh.results.html#pastas.plotting.bokeh.Bokeh.results) which I think looks better now. Somehow GH requires you need to re-review the PR @dbrakenhoff.

@raoulcollenteur raoulcollenteur merged commit eb9013f into dev Apr 4, 2024
11 of 12 checks passed
@raoulcollenteur raoulcollenteur deleted the bokeh branch April 4, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Indicates development of new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants