pmorissette / ffn

ffn - a financial function library for Python
pmorissette.github.io/ffn
MIT License
2.03k stars 300 forks source link

Not plotting #141

Closed bransonngai closed 3 years ago

bransonngai commented 3 years ago

matplotlib version 3.2.2 pandas version 1.1.4

while using the latest version of ffn, no plot showing in Jupyter notebook or spyder. (just show e.g. <matplotlib.axes._subplots.AxesSubplot at 0x2959a5e2160>)

timkpaine commented 3 years ago

Did you setup matplotlib to plot in jupyter? Doesn't sound like it has anything to do with this library.

MDDietz1 commented 3 years ago

I think it's a genuine issue.

ffn/core.py (lines 31-35) includes the following if "DISPLAY" not in os.environ: if matplotlib.__version__ > "2.": matplotlib.use("agg", force=False) else: matplotlib.use("agg", warn=False)

But there is no 'DISPLAY' variable set for me in my Spyder - and I believe this is not an issue as plotting works fine (using matplotlib) otherwise. So this code ends up overwriting the Spyder default setting for matplotlib and as a result there is no output. I don't know what the code snippet is trying to do and in what environments it is helpful - it seems to try and fix incomplete matplotlib settings which shouldn't be necessary.

I can get ffn output in Spyder as expected by adding the following at the beginning of my file to make sure there is an empty DISPLAY variable set. import os os.environ['DISPLAY'] = '' Alternatively, you can import ffn then reset matplotlib to Inline (%matplotlib Inline) and then run commands that print output