Closed chhab closed 5 years ago
That looks very odd. Is there an exception being displayed? Which version of matplotlib are you on? Do you run this in the Jupyter NB?
Thanks for getting back. There is no exception displayed. I am using matplotlib 2.1.0. When I run this in Jupyter I get a different error message "ValueError: Shape of passed values is (1, 3154), indices imply (1, 3153)" Thanks
For info only, I also get similar results using pyfolio from python 3.6.1. This is the backtrader latest (1.9.58.122) pyfolio example, the only change being to remove the gross_lev parameter which seems to have gone away.
This is a python venv, with pretty much everything built from source and latest packages all around, and the lightweight thonny editor. (due to an unrelated issue).
backtrader (1.9.59.122) Bottleneck (1.2.1) certifi (2017.11.5) chardet (3.0.4) cycler (0.10.0) decorator (4.1.2) empyrical (0.3.3) idna (2.6) ipython (6.2.1) ipython-genutils (0.2.0) jedi (0.11.1) matplotlib (2.1.1) numpy (1.13.3) pandas (0.21.1) pandas-datareader (0.5.0) parso (0.1.1) pexpect (4.3.1) pickleshare (0.7.4) pip (9.0.1) prompt-toolkit (1.0.15) ptyprocess (0.5.2) pyfolio (0.8.0) Pygments (2.2.0) pyparsing (2.2.0) python-dateutil (2.6.1) pytz (2017.3) requests (2.18.4) requests-file (1.4.2) requests-ftp (0.3.1) scikit-learn (0.19.1) scipy (1.0.0) seaborn (0.8.1) setuptools (28.8.0) simplegeneric (0.8.1) six (1.11.0) traitlets (4.3.2) urllib3 (1.22) utils (0.9.0) wcwidth (0.1.7)
Best.
can reproduce this error on the same system!
i am also running into this issue
I think in the end I managed to get it to more or less work by just using the same code within a jupyter notebook. If I remember correctly, some of the output areas were completely broken, but some work.
Same issue here. Was working fine a few weeks ago, would not create a single tear sheet correctly.
I am wondering if the issue might be due to this commit. Could someone do a quick test to verify that? You should run create_position_tear_sheet
or create_returns_tear_sheet
with return_fig=False
first and then try the same with return_fig=True
and check if the issue persists.
I am wondering if the issue might be due to this commit. Could someone do a quick test to verify that? You should run create_position_tear_sheet or create_returns_tear_sheet with return_fig=False first and then try the same with return_fig=True and check if the issue persists.
Checked it. No improvement. Only solution currently running it in Jupyter NB.
Marc
when run it in Ipython, first set %matplotlib inline
, to let figure display inside rather than pop out as a figure window. Or you could save the figure required. This problem might be a display setting issue
Can confirm this error still exists with default installations
Is there an exception or other output?
On Tue, Apr 10, 2018, 21:43 Dan733 notifications@github.com wrote:
Can confirm this error still exists with default installations [image: figure_2] https://user-images.githubusercontent.com/37793053/38557409-d4ffa10a-3c81-11e8-9ac0-b95794364d19.png
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/quantopian/pyfolio/issues/485#issuecomment-380084158, or mute the thread https://github.com/notifications/unsubscribe-auth/AApJmFiez_CiohS8KuBt8sTGf9U2ROZ1ks5tnKkGgaJpZM4Qipus .
@kakavegeta You are correct, it is a display issue. This generated a full chart:
# this makes plots not appear in a window
import matplotlib
matplotlib.use('Agg')
f = pf.create_returns_tear_sheet(returns, benchmark_rets=benchmark_rets, return_fig=True)
f.savefig('pyfolio_returns_tear_sheet.png')
@ostruk same issue here in windows10 machine with Anaconda and python 3.6.
In my case, I got problems with function argument:
return_fig
i´ve been reviewing the source code but it seems being correct so it´s really weird. So i´m trying to save the image to a png format file inside the source code.
same issue reporting
Just installed from pip git+... and had the same issue. A cursory glance at the code suggested a line may not have been indented appropriately even though here the line 953 appears to be indented correctly.
if benchmark_rets is not None:
returns = utils.clip_returns_to_benchmark(returns, benchmark_rets)
bmark_interesting = timeseries.extract_interesting_date_ranges(
benchmark_rets)
I changed it on my system, but the graphing issue persisted. I then jumped through some hoops to get the figures out by up-populating the return_fig variable. The saved figures were format correctly.
I tried the matplotlib.use('Agg') method but still suffer from the same issue.
Are you using jupyter notebook?
This issue still exists. This issue is happening because of
plt.show() in tears.py
I commented plt.show() in file tears.py inside function create_returns_tear_sheet() and then done the following
import matplotlib
fig = pf.create_returns_tear_sheet(returns, return_fig=True)
fig.savefig('returns_tear_sheet.pdf')
Alternatively you can also replace
plt.show() with plt.savefig("returns_tear_sheet.pdf") in tears.py
which will save a pdf tearsheet at the directory you are working
Thanks
@shintojoseph1234 Oh wow, thanks. Yeah that shouldn't be there. Odd that it causes that problem but anyway. I'll remove it.
Thanks for fixing this.
I tried finding plt.show() in tears.py but I couldn't find it. I found another solution that is using:
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('WebAgg')
plt.plot()
plt.show()
By doing this I was able to show the
Hope it helps :)
Hi guys! While all the solutions proposed here solved the same issue I had (thanks for that!), I still miss the very useful statistics showing for example 'annual return' and 'annual volatility' and 'worst drawdown periods'. Does anyone have an idea how to also include this in the graph?
Hi guys! Can you please tell me how to save and export the output of pyfolio with performance statistics. When i try to save create_returns_tear_sheet it cuts performance statistics text on savefig()
Hi guys! Can you please tell me how to save and export the output of pyfolio with performance statistics. When i try to save create_returns_tear_sheet it cuts performance statistics text on savefig()
Same question here. Is there a good way to save the statistics tables and also the charts?
Hi I am new to using python and have been working with pyfolio to generate the graphs for portfolio returns. I am getting a the following figure. Any help would be appreciated. Thanks