相关疑难解决方法(0)

matplotlib是否相当于MATLAB的datacursormode?

在MATLAB中,可以使用datacursormode当用户鼠标悬停时向图形添加注释.在matplotlib中有这样的事吗?或者我需要使用自己的事件来编写matplotlib.text.Annotation

python matplotlib

42
推荐指数
1
解决办法
2万
查看次数

光标下的matplotlib值

我正在使用matplotlib.imshow2D阵列的交互式显示.光标下的x/y坐标显示在窗口的左下角.是否也可以在光标下获取数组的值?

matplotlib

26
推荐指数
2
解决办法
2万
查看次数

使用twinx时控制跟踪器

在此输入图像描述

右下角的跟踪器(以红色突出显示)报告右侧相对于y轴的y值.

如何让跟踪器报告相对于左侧y轴的y值?

import matplotlib.pyplot as plt
import numpy as np

np.random.seed(6)
numdata = 100
t = np.linspace(0.05, 0.11, numdata)
y1 = np.cumsum(np.random.random(numdata) - 0.5) * 40000
y2 = np.cumsum(np.random.random(numdata) - 0.5) * 0.002

fig = plt.figure()

ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()

ax1.plot(t, y1, 'r-', label='y1')
ax2.plot(t, y2, 'g-', label='y2')

ax1.legend()
plt.show()
Run Code Online (Sandbox Code Playgroud)

我知道交换y1y2将使跟踪报告Y1值,但这也放置y1在右侧的刻度线,这不是我希望发生的.

ax1.plot(t, y2, 'g-', label='y2')
ax2.plot(t, y1, 'r-', label='y1')
Run Code Online (Sandbox Code Playgroud)

python matplotlib

7
推荐指数
1
解决办法
340
查看次数

使用 matplotlib 和 twinx 进行光标跟踪

I would like to track the coordinates of the mouse with respect to data coordinates on two axes simultaneously. I can track the mouse position with respect to one axis just fine. The problem is: when I add a second axis with twinx(), both Cursors report data coordinates with respect to the second axis only.

For example, my Cursors (fern and muffy) report the y-value is 7.93

Fern: (1597.63, 7.93)
Muffy: (1597.63, 7.93)
Run Code Online (Sandbox Code Playgroud)

If I use: …

python matplotlib

5
推荐指数
1
解决办法
3838
查看次数

将鼠标悬停在干线图中matplotlib中的某个点上时,是否可以显示标签?

我是matplotlib的新手,当鼠标悬停在那个点上时,我希望用x,y co-od标记茎干.当我搜索时,一切都是为了散点图(当在matplotlib中的一个点上空悬停时可能会出现标签?现在的代码是这样的:

def plot_matching(mzs,ints,matching,scan_num):
fig=p1.gcf()
fig.canvas.set_window_title('MS/MS Viewer')
rel_ints=relative_intensity(ints)
p1.xlim(min(mzs)-100,max(mzs)+100)
p1.ylim(min(rel_ints),max(rel_ints)+5)
p1.title('Scan Number:'+scan_num)
p1.xlabel('m/z')
p1.ylabel('Relative intensity')
mzs_rel=zip(mzs,rel_ints)    
for x,y in mzs_rel:
    x1=[]
    y1=[]
    x1.append(x)
    y1.append(y)
    markerline, stemlines, baseline=p1.stem(x1,y1)
    p1.setp(markerline, 'Marker', '')
    for m in matching:
        if x==m[1] and y>3.0:
            p1.setp(stemlines, linewidth=2, color='r')
            p1.text(x,y,m[0],fontsize=12)
            break
        else:
            p1.setp(stemlines,linewidth=2, color='g')
return p1
Run Code Online (Sandbox Code Playgroud)

干散图的散点图也会链接吗?

python matplotlib mouseover

4
推荐指数
1
解决办法
4972
查看次数

标签 统计

matplotlib ×5

python ×4

mouseover ×1