plot and figure windows

5 views (last 30 days)
Suleyman Suleymanov
Suleyman Suleymanov on 26 Feb 2015
Answered: Ayush on 21 Oct 2024
How can use plot function to indicate specific points in the figure window which displays an image?

Answers (1)

Ayush
Ayush on 21 Oct 2024
Hi,
To indicate specific points in the figure window which display an image, you can first use “hold on” which will allow you to overlay plots on the current figure without erasing the image. Then define the coordinates of the points you want to indicate on the figure and pass them to the “plot” function. Finally, use “hold off” to release the “hold on” the current figure. Refer to an example code below for better understanding:
% Read the image
img = imread('your_image.jpg');
% Display the image
imshow(img);
hold on; % Hold the current figure
% Define the points you want to plot
x = [50, 100, 150]; % X-coordinates of the points
y = [75, 125, 175]; % Y-coordinates of the points
% Plot the points on the image
plot(x, y, 'r*', 'MarkerSize', 10, 'LineWidth', 2);
% Release the hold on the current figure
hold off;

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!