mplfinance icon indicating copy to clipboard operation
mplfinance copied to clipboard

Unable to prevent plot from initial display

Open jmrichardson opened this issue 4 years ago • 1 comments

Hi,

I am trying to create a plot object which will later be used in a report. I am able to create the plot and store as object in a variable:

plot = mpf.plot(data.iloc[::5, :], type='line', volume=True, figratio=(15, 7), style='binance', title=ticker, closefig=True, returnfig=True)[0]

However, the plot shows on my windows screen initially as a small box, then the chart, then closes immediately. Because I am running the code in a loop, many windows appear and eventually errors out from memory consumption, plus it is a bit cumbersome to have the windows appear in the first place.

Thanks for any help! :)

jmrichardson avatar Sep 03 '21 03:09 jmrichardson

Sorry for the delay in replying. Had a lot of other distractions at the time you posted this.

In what OS environment are you running? Also, are you running in a [jupyter] notebook, or some IDE (which), as a python script in a linux or command prompt window?

In theory, depending on the environment, the code you have posted (with returnfig=True) should not display the plot until you call mpf.show(). However saving all of the returned Figure objects in memory (and thereby all the objects inside each Figure) as you are doing definitely has the potential of running out of memory.

Perhaps you can just save the plot images on disk, using the mplfinance savefig kwarg, and then display the images later?

Let me know. Thanks. All the best. --Daniel

DanielGoldfarb avatar Dec 16 '21 00:12 DanielGoldfarb