has2k1 / plotnine

A Grammar of Graphics for Python
https://plotnine.org
MIT License
3.92k stars 210 forks source link

How to show and wait for chart when using plotline in console program? #746

Closed fhg-isi closed 5 months ago

fhg-isi commented 5 months ago

When createing a chart with plotnine, I would expect following code to work.

chart = (ggplot(df, ...))
chart.show()

However, chart does not have a show method.

If I use

fig = chart.draw()
fig.show()

A plot window is created but different to matplotlib, the application does not wait until I closed the window.

I also tried

chart.draw()
plt.show()

=> What is the recommended way to display plotnine charts outside notebook environments?

fhg-isi commented 5 months ago

After half an hour I found out its chart.draw(True)

Maybe you want to include this in the getting started documentation or spend a function

 def show(self):
   self.draw(True)
fhg-isi commented 5 months ago

print(chart) also works. However, I would expect print to show something in the console, not to open a plot window.

has2k1 commented 5 months ago

There is an API change and the recommended method will be chart.show(). And print is being deprecated.