本文介绍了使用pcolor和Contourf时无法访问uicontextmenu(MATLAB R2014b)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对MATLAB并不是特别有经验,所以这可能是一个愚蠢的问题,但我将不胜感激.

I am not especially experienced with MATLAB so this might be a dumb question, but I would appreciate any help that can be given.

我有一些代码可以创建一些轴,将uicontextmenu分配给所述轴,然后在轴上绘制用户选择的图形.在每种绘图情况下,都需要右键单击图形(应如此)来访问uicontextmenu,它需要除pcolor和Contourf外.为什么会这样呢?我有什么办法可以解决这个问题?

I have some code that creates some axes, assigns a uicontextmenu to said axes, and then plots a graph of the user's choosing on the axes. The uicontextmenu is accessible by right-clicking on the graphs (as it should be) in every plot case it needs to EXCEPT for pcolor and contourf. Why would this be? Is there any way I can get around this?

通过广泛的调试,我发现uicontextmenu可以访问,直到调用了pcolor(或contourf)函数,然后它消失了.我想念什么?

Through extensive debugging I have found that the uicontextmenu is accessible until the pcolor (or contourf) functions are called and then it disappears. What am I missing?

编辑:根据要求,提供以下示例代码.如果使用pcolor,则不会显示uicontextmenu,如果使用plot,它将显示.我认为这与光标突出显示的数据有关.如果用鼠标右键单击绘制的数据,则两者均不显示任何内容.但是为什么呢?

As requested, example code below. If you use pcolor the uicontextmenu won't appear and if you use plot then it will. I think it has something to do with the data the cursor is highlighting. If your cursor right clicks on plotted data, nothing appears in both. But why is this?

axes;

stuff = uicontextmenu('Parent',ancestor(axes,'figure'));
stuffm = uimenu('Parent',stuff,'Label','Change something');
set(axes,'uicontextmenu',stuff);

x = randn(10);
y1=randn(10,1);
y2=randn(10,1);


plot(y1,y2)
%pcolor(x)

推荐答案

pcolor函数创建一个具有自己的uicontextmenu属性的surface图形对象.您必须在pcolor返回表面手柄之后进行设置:

The pcolor function creates a surface graphics object which has its own uicontextmenu property. You have to set it after the pcolor returns the surface handle:

h= pcolor(x);
set(h,'uicontextmenu',stuff);

这篇关于使用pcolor和Contourf时无法访问uicontextmenu(MATLAB R2014b)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 20:24