0
votes

I have formed a 2D matrix of 180X360. In fact, it is a LatXLong grid of 1°X1°. Each grid point has a value calculated according to my algorithm.

If I want to plot this LatXLong grid using any contour function, it is easy to do.

Now, what I need to do is to make this grid a clickable/ interactive contour plot in a way that when the user clicks anywhere on my grid plot, he gets an onscreen information or a further plot to be displayed specifically related to that grid point.

In short, I want to make a grid/contour plot in which all grid points are hyperlinks and linked to further background information.

2
What have you tried so far? check similar questions as well, something like this stackoverflow.com/questions/14684577/… or this one stackoverflow.com/questions/11233180/… - NKN
Thanks NKN.I am really interested in the second reference you mentioned. Can you please tell me how can get the coordinates as variables but not as writtne in the title of the figure or both at the same time. - Mushi

2 Answers

0
votes

To get started, look into ginput and text. ginput will let you click on points in your plot and return the coordinates to some function that can generate information to be displayed in the current plot using text of by opening another figure.

You can use ginput in a loop to display multiple data points as you go:

for t = 1:10
    [x,y] = ginput(1);
    text(x,y,'some info');
end

I don't know of a way to remove the gird lines. NKN's solution might do that for you.

1
votes

check this answer: if you don't want to have the variable as title of the plot, you can modify the code as:

function mouseExample()
    h = plot(rand(10,1), 'o-');
    set(h, 'ButtonDownFcn',@buttonDownCallback)

    function out = buttonDownCallback(o,e)
        p = get(gca,'CurrentPoint');
        out = p(1,1:2);
        % title( sprintf('(%g,%g)',p) ) % --> no need this line anymore
    end
end

the information is saved in the P variable that you can use later.