matlab - 使单击 MATLAB 绘图标记绘制子图

标签 matlab plot interactive marker clickable

在 Matlab 2011b 中,我有一个多维矩阵,最初将其呈现为 2 个维度的二维图。我希望使标记可以用鼠标左键单击。单击标记会绘制一个新的按单击值切片的其他维度的图形。

这个问题与Matlab: Plot points and make them clickable to display informations about it有关但我想运行一个脚本,而不仅仅是弹出有关点击点的数据。

谷歌搜索提示可以使用 ButtonDownFcn,但我发现的示例需要手动绘制每个点并附加处理程序,如下所示:

hp = plot(x(1), y(1), 'o');
set(hp, 'buttondownfcn', 'disp(1)');

由于主图中有很多标记,是否可以只将处理程序附加到整条曲线并使用索引(最好)或单击标记的坐标调用子图绘制函数?

最佳答案

这是您的需求的想法,如果我了解您的要求,应该可以帮助您入门。

在这种情况下,当您选择一条曲线时,它将在保留颜色的底部子图中绘制它。

function main
subplot(211)
h = plot (peaks);

set (h,'buttondownfcn', @hitme)
end

function hitme(gcbo,evendata)
subplot (212)
hold on;

col = get (gcbo,'Color');
h2 =  plot (get (gcbo,'XData'),get (gcbo,'YData'));
set (h2,'Color', col)

pt = get (gca, 'CurrentPoint');
disp (pt);
end

您可以通过简单地在 hitme 函数中编写 get(gcbo) 来探索您的 get 选项。

关于matlab - 使单击 MATLAB 绘图标记绘制子图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10249361/

相关文章:

python - `plt.style.context` 中的 `matplotlib` 可以用作 Python 3.6 中的 `decorator` 吗?

r - 如何重新缩放 R 中直方图的 Y 轴(频率)?

php - 使用 PHP 的交互式 shell

c - Linux C : "Interactive session" with separate read and write named pipes?

python - Bokeh:动态更新垂直线的位置。

c - 如何解决 matlab 示例 "fulltosparse.c"的错误

java - 无法在matlab中执行 'DocumentBuilderFactory'

matlab - 在matlab中将新行写入文本文件

plot - gnuplot 需要很长时间才能从大型数据集生成 3D 表面

matlab - 将矩阵转换为单行向量的最简单方法