簡體   English   中英

Python Plotly 散極懸停模式

[英]Python Plotly Scatterpolar hovermode

我是 Python 和一般編程的新手。 使用 Jupyter Notebooks,我制作了一個帶有兩條跡線的 Scatterpolar plot。 當我將鼠標 hover 放在 plot 上時,它向我顯示了其中一條軌跡的數據(我的鼠標最接近的軌跡)。 但我想查看兩條跡線的數據。 我怎么做? 我可以通過將“懸停模式”更改為“x”來使用常規的 Scatter plot 來做到這一點。 但它不適用於 Scatterpolar 圖。 懸停模式的其他選項對我也不起作用。

作為一個例子,我在這里放了一些更簡單的代碼來說明這個問題:

import numpy as np
from plotly.offline import iplot
import plotly.graph_objs as go

th = np.arange(0, 361, 1)
r1 = np.random.randn(360)
r2 = np.random.randn(360)

fig = go.Figure()
fig.add_trace(go.Scatterpolar(r=r1, theta=th, mode='lines'))
fig.add_trace(go.Scatterpolar(r=r2, theta=th, mode='lines'))
fig.update_layout(hovermode='x unified')

在 Jupyter Notebook 中使用上述代碼,我在極坐標 plot 上得到兩條凌亂的軌跡,當我將鼠標懸停在 hover 上時,我只看到其中一條軌跡的數據。 我想查看兩條跡線的數據。 任何幫助將不勝感激。 非常感謝!

我不知道我是否完全理解了你的最終目標,但你可以做的第一件事是讓散點圖不那么混亂,就是讓 change mode='markers' By default, a single hover label will appear for the point underneath the cursor, so if you hover over a point with (r1, th) coordinates these will show in the label, with the same happening for points with (r2, th). 現在對於您提出的情況, fig.update_layout(hovermode='x unified')行對結果沒有任何影響。

暫無
暫無

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

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