我正在尝试将绘图直方图导出到svg文件。在我尝试处理大量数据点之前,此方法效果很好。下面的代码可用于1000000个模拟数据点,但可破解1000万个点。
$response = $this->response;
$response = $response->withStatus(200,"OK");
return $response; // returning response will stop controller from rendering a view.
如果使用10000000个模拟数据点运行,我会收到以下错误消息(下面是完整的堆栈跟踪):
import plotly.graph_objs as go
import plotly.io as pio
import numpy as np
# simulate small input data: this works
# data_1 = list(np.random.randint(0, 2**63, 1_000_000))
# data_2 = list(np.random.randint(0, 2**63, 1_000_000))
# simulate larger input data: this works
data_1 = list(np.random.randint(0, 2**63, 10_000_000))
data_2 = list(np.random.randint(0, 2**63, 10_000_000))
# assemble two histograms and plot them into one figure
g1 = go.Histogram(x=data_1, opacity=0.75)
g2 = go.Histogram(x=data_2, opacity=0.75)
data = [g1, g2]
figure = go.Figure(data=data)
# write the plot as html, this works
plotly.offline.plot(figure, auto_open=True, filename="/tmp/foo.html")
# writing the plot as svg (or png) file doesn't work
pio.write_image(figure, "/tmp/foo.svg")
问题是:使用我的真实数据集,我不能简单地减少点数。有谁知道,这是怎么回事,以及如何解决此问题?
它看起来有点像orca服务器超时,因为计算时间太长,但是服务器的超时时间(默认情况下)设置为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.
,即没有超时。我还尝试更改服务器的端口(如建议的here),但这没有帮助。
我正在使用3.3.0和orca 1.1.1。我的orca配置(None
)如下:
print(pio.orca.config)
orca configuration
------------------
executable: orca
port: None
timeout: None
default_width: None
default_height: None
default_scale: 1
default_format: png
mathjax: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js
topojson: None
mapbox_access_token: None
constants
---------
plotlyjs: /home/m00am/miniconda3/envs/my_conda_env/lib/python3.6/site-packages/plotly/package_data/plotly.min.js
config_file: /home/m00am/.plotly/.orca
答案 0 :(得分:0)
这看起来像是超时问题,不幸的是,orca的配置中的timeout
参数与请求超时无关,该请求超时似乎硬编码在server sources中。您可以尝试使用更大的requestTimeout
构建orca或在存储库中提交问题。