question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

problem with auto plotting data

See original GitHub issue
model = KElbowVisualizer(KMeans(init='k-means++', max_iter=10000, n_init=10), k=(4,12))
model.fit(X)
model.elbow_value_

Since I did not use mode.show (), I expect the above code not to show me a plot, but it does.

Desktop :

  • OS: Windows 10
  • Python Version 3.8.10[anaconda]
  • Yellowbrick Version ‘1.3.post1’

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
maghaalicommented, Jun 18, 2021

Hi @spacelover92 @jhgrey-su, and thanks for using Yellowbrick!

The auto-plotting you’re observing is likely related to Jupyter notebook and not Yellowbrick. Jupyter notebook is setting the inline backend as the default. In older versions of Jupyter notebook, you would have to turn on inline plotting manually with %matplotlib inline; nowadays it is set as turned on by default. It’s similar to the reason why doing print(viz.elbow_value_) is the same as viz.elbow_value_ when you’re inside a Jupyter notebook.

If you run the same Yellowbrick code in the command line, you won’t get a plot without the call to show(). You can also explicitly pass show=False to a Visualizer to ensure the plot isn’t shown (note that the plot may still show inside a Jupyter notebook where inline is turned on):

model = KMeans(
    init='k-means++', 
    max_iter=10000, 
    n_init=10
)
viz = KElbowVisualizer(model, k=(4,12), show=False)
viz.fit(X)
print(viz.elbow_value_)

It appears you can circumvent plotting in a Jupyter notebook if that solution is more appropriate to you.

Thanks again for being Yellowbrick users!

Thank you for your answer Adding

plt.close("all")

at the end of code cell worked for me in jupyter notebook

0reactions
bbengfortcommented, Jul 10, 2021

@jhgrey-su glad that you figured it out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with Plots or Graphics Device in the RStudio IDE
1) "Error in plot.new() : figure margins too large" · 2) Graphic with missing or distorted components · 3) Reset your graphics device....
Read more >
Drawing objects do not plot and are missing from print preview ...
Possible causes of this issue are: Incorrect Plotter Configuration. Layers set to No Plot or turned off. Objects placed on the Defpoint layer....
Read more >
Problems with Data Filter and Plots Autoupdating
I'm trying to use sliders and have a data filter at the same time. The problem I have is that when I open...
Read more >
Two Excel Chart Problems solved in two minutes ... - YouTube
There are two issues with Excel charts. Two Excel Chart Problems ... One is that dates show up in a chart where there...
Read more >
How to solve the overplotting issue in scatter plots ? [R Data ...
How to solve the overplotting issue in scatter plots using ggplot2?.Check out our website for more Data Science and Statistics ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found