has2k1 / plotnine

A Grammar of Graphics for Python

Home Page:https://plotnine.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

fhg-isi opened this issue · comments

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?

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)

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

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