ranaroussi / quantstats

Portfolio analytics for quants, written in Python
Apache License 2.0
4.82k stars 841 forks source link

Plots don't display when using matplotlib backend qt #320

Open cppt opened 10 months ago

cppt commented 10 months ago

As described, the first block successfully displays inline.

When setting matplotlib backend to qt, to allow pop-out figures/interactive plottting, nothing is displayed (aside from a momentary 'Figure 1' pop up. Working in Ubuntu 22.04 using Spyder 5.3.3 and Python 3.9 with the most recent package version. What am I missing?

import quantstats as qs
%matplotlib inline

# displays successfully in Plots tab in Spyder
stock = qs.utils.download_returns('SPY')
qs.plots.returns(stock) 

# doesn't show anything
%matplotlib qt
qs.plots.returns(stock) 
git-shogg commented 10 months ago

Hi @cppt , I have raised a pull request to change some of the default behaviour of the quantstats package. It might be possible that the reason why you are not seeing the graph is because you are running the script in a non-interactive mode (e.g. from the command line python filename.py) if you run this same thing from a Jupyter notebook you should receive the plot as shown below.

image

Does that help answer your question?

grzesir commented 2 months ago

Check out https://github.com/Lumiwealth/quantstats_lumi, which is being updated regularly. We are a fork of this library that is being maintained by Lumiwealth