Hi there, I’m having problems creating a PDF from a BarPolar figure object!
My Code
import plotly.graph_objects as go
def create_polar_bar(r: list, theta: list, title: str):
fig = go.Figure(go.Barpolar(
r=r,
theta=theta,
# layout
marker_line_color="black",
marker_line_width=2,
opacity=0.8
))
fig.update_layout(
title=title,
font_size=16,
showlegend = True,
legend_font_size=16,
)
fig.write_image(file=f"{title}.pdf", format="pdf")
# fig.write_html(file=f"{title}.html")
theta = ['File', 'DNS', 'Internet', 'ICMP', 'Registry', 'Process', 'Mutex', 'Module', 'System', 'Service', 'Memory', 'Thread', 'Keyboard', 'Driver', 'User', 'Share', 'Debug', 'Kernel Debug', 'Environment', 'Ini', 'URL', 'Window']
r = [67.0, 0.0, 0.0, 0.0, 19.0, 7.0, 0.0, 203.0, 19.0, 6.0, 4.0, 4.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, 0.0, 0.0, 2.0]
create_polar_bar(r, theta, "Visualization")
When I use the function write_html
the code works perfectly. But the code throws some exceptions when I’m trying to save it as static PDF image.
Traceback
Traceback (most recent call last):
File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\io\_orca.py", line 1559, in to_image
figure=fig_dict, format=format, scale=scale, width=width, height=height
File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\retrying.py", line 212, in call
raise attempt.get()
File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\retrying.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\six.py", line 693, in reraise
raise value
File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\retrying.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\io\_orca.py", line 1474, in request_image_with_retrying
raise OSError("522: client socket timeout")
OSError: 522: client socket timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\input.py", line 43, in <module>
create_polar_bar(r, theta, "Visualization")
File "...\plot.py", line 21, in create_polar_bar
fig.write_image(file=f"{title}.pdf", format="pdf")
File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\basedatatypes.py", line 2824, in write_image
return pio.write_image(self, *args, **kwargs)
File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\io\_orca.py", line 1767, in write_image
fig, format=format, scale=scale, width=width, height=height, validate=validate
File "C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\io\_orca.py", line 1591, in to_image
info=status_str
ValueError:
For some reason plotly.py was unable to communicate with the
local orca server process, even though the server process seems to be running.
Please review the process and connection information below:
orca status
-----------
state: running
executable: C:\Users\winklerrr\AppData\Roaming\npm\orca.CMD
version: 1.2.1
port: 50421
pid: 864
command: ['C:\\Users\\winklerrr\\AppData\\Roaming\\npm\\orca.CMD', 'serve', '-p', '50421', '--plotly', 'C:\\Users\\winklerrr\\AppData\\Roaming\\Python\\Python37\\site-packages\\plotly\\package_data\\plotly.min.js', '--graph-only', '--mathjax', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js']
My Setup
I’m working under Windows 10 with Python 3.7.
I installed Orca 1.2.1
with npm.
What I already tried
When I try to run the following command manually (with the --debug
flag at the end) nothing happens and no output is generated at all:
C:\Users\winklerrr\AppData\Roaming\npm\orca.CMD serve -p 50221 --plotly C:\Users\winklerrr\AppData\Roaming\Python\Python37\site-packages\plotly\package_data\plotly.min.js --graph-only --mathjax https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js --debug