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

Plots not showing in Jupyter/.ipynb #785

Open
Dorota-D opened this issue Nov 5, 2024 · 7 comments
Open

Plots not showing in Jupyter/.ipynb #785

Dorota-D opened this issue Nov 5, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@Dorota-D
Copy link

Dorota-D commented Nov 5, 2024

Environment:

  • Windows 11
  • Python 3.11.5
  • VSCode 1.95.1
  • matplotlib: 3.8.0
  • seaborn: 0.13.2
  • mljar-supervised: 1.1.12

I wanted to plot the optimized ML model fits in my jupyter notebook file, but the plots did not show up - only the text line, e.g., <Axes: xlabel='total_bill', ylabel='tip'>. Using %matplotlib inline did not help. I can still save the plots as JPG, but that is not the point. I found that the problem appears when I activate AutoML. This conflict appears even in the most basic example:

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")
tips.head()
sns.scatterplot(data=tips, x="total_bill", y="tip")

Here, the plot shows up.
After adding a cell with AutoML, the plot "disappears".

from supervised import AutoML
sns.scatterplot(data=tips, x="total_bill", y="tip")

How can I resolve this?

@pplonski pplonski self-assigned this Nov 5, 2024
@pplonski pplonski added the bug Something isn't working label Nov 5, 2024
@pplonski
Copy link
Contributor

pplonski commented Nov 5, 2024

Hi @Dorota-D,

Thank you for reporting the issue. Looks like AutoML overwrites the matplotlib backend.

For quick fix please execute:

import matplotlib
matplotlib.use('WebAgg') 

you can check list of available backends here https://matplotlib.org/stable/users/explain/figure/backends.html#interactive-backends

Please let me know if it works for you.

@Dorota-D
Copy link
Author

Dorota-D commented Nov 5, 2024

Hi Piotr,

Thanks for your quick reply.
No, unfortunately not, the problem remains and "WebAgg" also completely disables the plot even before AutoML loads :(

@Dorota-D
Copy link
Author

Dorota-D commented Nov 5, 2024

Another thing - I've added another cell at the end:

fig, ax = plt.subplots()

fruits = ['apple', 'blueberry', 'cherry', 'orange']
counts = [40, 100, 30, 55]
bar_labels = ['red', 'blue', '_red', 'orange']
bar_colors = ['tab:red', 'tab:blue', 'tab:red', 'tab:orange']

ax.bar(fruits, counts, label=bar_labels, color=bar_colors)

ax.set_ylabel('fruit supply')
ax.set_title('Fruit supply by kind and color')
ax.legend(title='Fruit color')

plt.show()

I got the following error message: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown

@pplonski
Copy link
Contributor

pplonski commented Nov 5, 2024

One more try:

matplotlib.use('module://matplotlib_inline.backend_inline')

@Dorota-D
Copy link
Author

Dorota-D commented Nov 5, 2024

Works! Thank you!

@Dorota-D Dorota-D closed this as completed Nov 5, 2024
@pplonski
Copy link
Contributor

pplonski commented Nov 5, 2024

Great! May I ask what is your use case for AutoML? I will reopen the issue, because it should be fixed in the package.

@pplonski pplonski reopened this Nov 5, 2024
@Dorota-D
Copy link
Author

Dorota-D commented Nov 5, 2024

Research :) Our group developed simple models in Weka, but we'd like to integrate ML with our other scripts. scikit is ok, but we feel we need something robust and quick. So, now we're testing AutoML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants