簡體   English   中英

plotly:大量數據點

[英]plotly: huge number of datapoints

我正在嘗試使用 plotly 繪制具有大量數據點(2mm-3mm)的東西。

當我跑

py.iplot(fig, filename='test plot')

我收到以下錯誤:

Woah there! Look at all those points! Due to browser limitations, the Plotly SVG drawing functions have a hard time graphing more than 500k data points for line charts, or 40k points for other types of charts. Here are some suggestions:
(1) Use the `plotly.graph_objs.Scattergl` trace object to generate a WebGl graph.
(2) Trying using the image API to return an image instead of a graph URL
(3) Use matplotlib
(4) See if you can create your visualization with fewer data points

If the visualization you're using aggregates points (e.g., box plot, histogram, etc.) you can disregard this warning.

那么我嘗試用這個保存它:

py.image.save_as(fig, 'my_plot.png')

但是后來我收到了這個錯誤:

PlotlyRequestError: Unknown Image Server Error

我該如何正確執行此操作? 我不在乎它是我筆記本中的靜止圖像還是交互式顯示。

一種選擇是對您的數據進行下采樣,不確定您是否願意: https : //github.com/devoxi/lttb-py

我在瀏覽器中有大數據集的 plotly 也有問題 - 如果有人有解決方案,請寫! 謝謝!

Plotly 在這方面似乎真的很糟糕。 我只是想創建一個有 500 萬個點的箱線圖,這在簡單的 R 函數“箱線圖”中沒有問題,但情節圖為此無休止地計算。

改善這一點應該是一個主要問題。 並非所有數據都必須保存(和顯示)在 plotly 對象中。 這是我猜的主要問題。

您可以嘗試使用render_mode參數。 例子:

import plotly.express as px
import pandas as pd
import numpy as np

N = int(1e6) # Number of points

df = pd.DataFrame(dict(x=np.random.randn(N),
                       y=np.random.randn(N)))

fig = px.scatter(df, x="x", y="y", render_mode='webgl')
fig.update_traces(marker_line=dict(width=1, color='DarkSlateGray'))
fig.show()

在我的電腦中N=1e6大約需要 5 秒才能看到情節,“交互性”仍然非常好。 N=10e6時,大約需要 1 分鍾,並且繪圖不再響應(即縮放、平移或任何操作都非常慢)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM