Plotting and labelling a scatter /line plot in matlab

1 view (last 30 days)
hi!
I am trying to plot and label line/scatter plot of two columns in a dataset , the first column are the time values to be plotted on x - axis and the corresponding pitch values are in the second column of the dataset to be plotted on the y-axis. The labels for each point are in third column of the dataset labelled as notation. The columns of dataset are 'char' array and the length of dataset is x 3.
Time Pitch notation
2.64 329.63 'GM'
2.64 329.63 'GM'
3.49 261.63 'SM'
4.09 349.23 'MM'
6.27 261.63 'SM'
6.50 349.23 'MM'
6.72 329.63 'GM'
6.75 349.23 'MM'
7.02 329.63 'GM'
7.28 349.23 'MM'
7.32 329.63 'GM'
8.06 261.63 'SM'
8.44 329.63 'GM'
9.36 261.63 'SM'
9.95 349.23 'MM'
11.81 329.63 'GM'
12.04 246.94 'NL'
12.09 261.63 'SM'
12.29 329.63 'GM'
I have used the following commands :
ds = dataset('XLSFile', 'tilakkamodgatannotation.xlsx','sheet', 2);
l = cellstr(ds_new(:,3));
plot(ds(:,1), ds(:,2), 'rx')
text(ds(:,1), ds(:,2), l);
I get a scatter plot with following error :
Error using text Invalid parameter/value pair arguments
  3 Comments
avantika
avantika on 4 Sep 2013
Edited: avantika on 4 Sep 2013
sorry for that error , but I am using the following commands and getting an error:
ds = dataset('XLSFile', 'tilakkamodgatannotation.xlsx','sheet', 2);
time = ds(:,1);
pitch = ds(:,2);
l = cellstr(ds(:,3));
plot(time, pitch, 'rx')
text(time, pitch, l,'horizontal','left', 'vertical','bottom');
error:
Error using text Invalid parameter/value pair arguments
avantika
avantika on 4 Sep 2013
Hi!
the problem got solved , i have used the following commands : time = ds(:,1);
pitch = ds(:,2); l = cellstr(ds(:,3));
plot(time, pitch,'.','color','r')
text(double(time), double(pitch), l,'fontsize',6, 'color','b','rotation',45,'horizontal','left', 'vertical','bottom');

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!