簡體   English   中英

Plotly:當點數超過 20 點時,散點 plot 的標記消失

[英]Plotly: markers of scatter plot vanish when there are more than 20 points

這個問題快把我逼瘋了。 出於某種原因,當我嘗試使用 plotly 在散點 plot 中 plot 超過 20 個點時,標記消失了。 我做了一個最小可重現的例子,如下所示:

def plot(n):
    
    fig = go.Figure()
    
    fig.add_trace(go.Scatter(x=np.arange(n), 
                             y=np.arange(n), 
                             marker=dict(symbol='circle', color='Blue', size=6)
                            ))
    
    fig.show()

以下是一些 n 值的輸出(在 jupyter 筆記本中):

n=10 的輸出

n=15 的輸出

n=19 的輸出

n=20 的輸出

在此處輸入圖像描述

如您所見,當 I go 從n=19n=20時,標記消失。 O 嘗試刪除go.Scattermarker的定義,但沒有幫助。

有人知道這里到底發生了什么嗎? 執行之間的plot function 絕對沒有變化

If you don't set the value of the mode argument in go.Scatter() then plotly will use the default settings to determine how to plot data, ie it will plot lines and markers for less than 20 points and lines otherwise. 要更改它,請將mode設置為適當的值: mode='markers'到 plot 標記或mode='lines+markers'到 plot 線條和標記:

import plotly.graph_objects as go
def plot(n):
    
    fig = go.Figure()
    fig.add_trace(go.Scatter(x=np.arange(n), 
                             y=np.arange(n),
                             mode='lines+markers',
                             marker=dict(symbol='circle', color='Blue', size=6)
                            ))
    fig.show()

暫無
暫無

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

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