Skip to content

Running plotly headlessly gives runtime error #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Immortalin opened this issue Jan 8, 2016 · 0 comments
Closed

Running plotly headlessly gives runtime error #381

Immortalin opened this issue Jan 8, 2016 · 0 comments

Comments

@Immortalin
Copy link

When running the following code headlessly i.e. outside IPython, via the python interpreter

import plotly.tools as tls
import plotly.offline.offline as offline
tls.mpl_to_plotly(plt.gcf())

gives the following error:

File "../zipline/examples/dual_moving_average.py", line 116, in analyze
    offline.plot(tls.mpl_to_plotly(plt.gcf()))
  File "/home/immortalin/.local/lib/python3.4/site-packages/plotly/tools.py", line 478, in mpl_to_plotly
    matplotlylib.Exporter(renderer).run(fig)
  File "/home/immortalin/.local/lib/python3.4/site-packages/plotly/matplotlylib/mplexporter/exporter.py", line 49, in run
    self.crawl_fig(fig)
  File "/home/immortalin/.local/lib/python3.4/site-packages/plotly/matplotlylib/mplexporter/exporter.py", line 116, in crawl_fig
    self.crawl_ax(ax)
  File "/home/immortalin/.local/lib/python3.4/site-packages/plotly/matplotlylib/mplexporter/exporter.py", line 147, in crawl_ax
    self.crawl_legend(ax, legend)
  File "/home/immortalin/.local/lib/python3.4/site-packages/plotly/matplotlylib/mplexporter/exporter.py", line 167, in crawl_legend
    self.draw_text(ax, child, force_trans=ax.transAxes)
  File "/home/immortalin/.local/lib/python3.4/site-packages/plotly/matplotlylib/mplexporter/exporter.py", line 211, in draw_text
    style=style, mplobj=text)
  File "/home/immortalin/.local/lib/python3.4/site-packages/plotly/matplotlylib/renderer.py", line 514, in draw_text
    if not mpltools.check_corners(props['mplobj'], self.mpl_fig):
  File "/home/immortalin/.local/lib/python3.4/site-packages/plotly/matplotlylib/mpltools.py", line 42, in check_corners
    inner_corners = inner_obj.get_window_extent().corners()
  File "/home/immortalin/.local/lib/python3.4/site-packages/matplotlib/text.py", line 959, in get_window_extent
    raise RuntimeError('Cannot get window extent w/o renderer')
RuntimeError: Cannot get window extent w/o renderer

I have tried explicitly setting the matplotlib backend renderer but to no avail. Refer 353, offline.plot is from #378 . The problem seems to be with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant