Plotting with image together with scatter plot

조회 수: 29 (최근 30일)
Ian
Ian 2014년 12월 8일
답변: matt dash 2014년 12월 8일
I would like to plot an image together with scatter plot on a custom figure file that I had created but I am not sure why it dosent appear together, please advice, thanks
Below is the code that I had tried:
h=openfig('figure.fig'); handles = guihandles(h); i = imread('image.jpg'); scatter(handles.axes1,5,6)
hold on; imshow(i); hold off;

채택된 답변

matt dash
matt dash 2014년 12월 8일
You want to use the command "image", not "imshow". Imshow is meant to just display an image for quick viewing, it not meant to be part of a larger code that does anything with the image. You may also need to 1) draw the image first, so it's on the bottom (or give your scatter a z coordinate that is above the image, using scatter3) 2) use "axis image" to property scale the axes to the image.

추가 답변 (1개)

Thorsten
Thorsten 2014년 12월 8일
편집: Thorsten 2014년 12월 8일
scatter(handles.axes1,5,6) just plots a single points at (5,6). Maybe that's the error. To scatter 100 points all over the image, use
I = rgb2gray(imread('peppers.png'));
imshow(I)
hold on
scatter(size(I,2)*rand(1,100), size(I,1)*rand(1,100), 'r.')
  댓글 수: 1
Ian
Ian 2014년 12월 8일
Thanks for your quick reply, but the issue is that I am unable to plot the image and the scatter plot on the same axes. When I plot the image, it will open a new figure. I want the Image and the scatter to be on the same axes

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by