-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
DOC: use notebook-style for plot_ols_3d #22547
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
DOC: use notebook-style for plot_ols_3d #22547
Conversation
Ah, so for my previous PR I forgot to create a separate branch, so that commit and the merge is included here. Is that a problem? I'll do a hard git reset on my |
Thanks for your PR!
I think it's fine since we use squash + merge on the PR, so as long as the diff makes sense we don't care about the commit history.
Indeed, it seems like the needed change is the following one, it is small so I think it is fine to do it in this PR: ax = Axes3D(fig, elev=elev, azim=azim, auto_add_to_figure=False)
fig.add_axes(ax) Edit: having said we run our examples with matplotlib 2.2.3 to make sure they run with an old matplotlib version and maybe this parameter does not exist, this needs to be double-checked ... |
examples/linear_model/plot_ols_3d.py
Outdated
@@ -29,12 +31,15 @@ | |||
y_train = y[:-20] | |||
y_test = y[-20:] | |||
|
|||
# %% | |||
# Next we fit a linear regression model. | |||
|
|||
ols = linear_model.LinearRegression() | |||
ols.fit(X_train, y_train) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something which would be nice as well, would be to move the imports in the cell where there are first used (e.g. the matplotlib import to the last cell where we do the plot). This would look closer to what you would write if you were writing the code live.
In matplotlib 2.2.3
Briefly looking at the matplotlib code it seems that if an axis is already added to a figure, there's no harm in adding it again. But I guess the code is kind of confusing until matplotlib 3.5 when
I've made these changes as you recommend. |
Thanks a lot for checking the old matplotlib, I think you are right but I also think I found a way with |
Looks great, thanks! |
The plots don't look exactly the same but let's say this is good enough, merging thanks a lot! |
By the way, thanks for noticing the warning! I opened #22586 to get rid of similar warnings in other examples. |
Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
Reference Issues/PRs
Addresses #22406.
What does this implement/fix? Explain your changes.
Fix notebook-style issues in
examples/linear_model/plot_ols_3d.py
.# #######
pattern to# %%
.Any other comments?
On my machine I get the following depreciation warning in the built HTML:
I'm happy to remedy this in a separate PR (or in this one if you prefer).