Using a figure to create a new one, then spectrogram to plot on it, how do I mark a certain point on the existing figure?
Asked
Active
Viewed 850 times
1 Answers
0
Use the hold feature:
hold on
This way, you can make another plot and it will overlay the spectrogram.
An example (you probably didn't see your marker because it wasn't large enough):
>> t=0:0.001:2; % 2 secs @ 1kHz sample rate
>> y=chirp(t,100,1,200,'q'); % Start @ 100Hz, cross 200Hz at t=1sec
>> spectrogram(y,128,120,128,1E3); % Display the spectrogram
>> hold on
>> plot(200,1,'bx','MarkerSize',20,'LineWidth',20); %Overlay a large, blue X

Adam27X
- 889
- 1
- 7
- 16
-
I tried it, for example hold on; plot(x,y,'bo'); and it didn't show on the plot – winuall Oct 26 '12 at 10:31
-
@Izhak Please see my above edit. It is likely that you didn't make your marker large/thick enough to see it. – Adam27X Oct 26 '12 at 13:59
-
Still nothing. But if I plot an asterisk first then use hold on; and plot spectrogram, the asterisk shows, and plotting more markers works well as you said. bug? – winuall Oct 26 '12 at 14:15
-
@Izhak That's pretty strange. The order in which you plot shouldn't matter when using this feature. Maybe you're plotting your spectrogram in some odd way? Either way, glad it worked. – Adam27X Oct 26 '12 at 15:57
-
@Izhak This is probably because of your 3-D renderer (OpenGL or zbuffer) which draws the spectrogram. Use `set(gcf, 'renderer', 'painters')` to use a simpler renderer that should plot layers properly. – Eitan T Oct 27 '12 at 22:24