Skip to content

Running plotly headlessly gives runtime error #381

Closed
@Immortalin

Description

@Immortalin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions