Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top