I have the following code:
x=[1:1:5] a=rand*10 y=[2,a,3,5,4] set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]); plot(x,y) hold on plot(2,a,'.','markersize',40) % Create and display the text label
url = 'cam.ac.uk'; labelStr = ['<html><a href="">' 'SPEC' '</a></html>']; jLabel = javaObjectEDT('javax.swing.JLabel', labelStr); [hjLabel,hContainer] = javacomponent(jLabel, [1000,800,30,20], gcf); % WHAT SHOULD [1000, 800, 30, 20] BE IF I WANT THE LABEL TO BE AT THE SAME
% POSITION AS THE DOT ON THE PLOT?
% Modify the mouse cursor when hovering on the label
hjLabel.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.HAND_CURSOR)); % Set the label's tooltip
hjLabel.setToolTipText(['Visit the ' url ' website']); % Set the mouse-click callback
set(hjLabel, 'MouseClickedCallback', @(h,e)web(['http://' url], '-browser'))
How can I get the position of the point which is plotted randomly? Now it looks like this:
I want the "SPEC" hyperlink to appear just next to the randomly plotted point. How can I do that?
Best Answer