簡體   English   中英

在散點圖中的繪圖點上標記

[英]Marker over plotly dots in a scatterplot

我有一個散點圖 - 我想要做的是在不同的點上有特定的字符(比如“*”或“#”)。 如下圖所示的兩個點(粉紅色標記)。

我該怎么做(可能使用這些)?

在此處輸入圖片說明

這是一個可能合適的示例。 可以從此頁面選擇標記。 開放式標記看起來很有趣,因為它可以包含一個較小的標記。 但是您也可以向 x 和 y 添加一個小的偏移量以定位任何標記。

import random
import plotly.graph_objects as go

N = 20

x1 = [random.gauss(2, .5) for _ in range(N)]
y1 = [random.gauss(2, .5) for _ in range(N)]

x2 = [random.gauss(4, .4) for _ in range(N)]
y2 = [random.gauss(2, .2) for _ in range(N)]

x3 = [random.gauss(3, .4) for _ in range(N)]
y3 = [random.gauss(4, .3) for _ in range(N)]

# x,y for rightmost dot
max_xy = [max(zip(x1,y1)), max(zip(x2,y2)), max(zip(x3,y3))]
max_x = [m[0] for m in max_xy]
max_y = [m[1] for m in max_xy]

fig = go.Figure()
fig.add_trace(go.Scatter(
    x = x1+x2+x3,
    y = y1+y2+y3,
    mode='markers',
    marker=dict(
        size=15,
        color=[.3] * N + [.65] * N + [.8] * N,
        colorscale='jet'
    )
))
fig.add_trace(go.Scatter(
    x = max_x,
    y = max_y,
    mode='markers',
    marker=dict(
        size=30,
        line=dict(width=3, color='pink'),
        symbol=[117, 118, 114]
    )
))
fig.update_layout(showlegend=False)
fig.show()

結果圖

暫無
暫無

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

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