Stair Plot problem
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have four data points along a date axis, which I want to plot as a stairs.
the data are
Data = [9;9;10;9]
the dates are in chronological order, but don't really mater here I think.
My problem is that when plotting as
stairs(Dates,Data)
matlab marks six data points instead of the actual four. I realize that this is necessary in order to do the corners, but isn't there a way to keep the line while having the markers only on the actual datapoints.
And more importantly, as it is now the plot rises to 10 (and has a marker at 9 at the same time) before the matching date, and goes back to 9 at the time it should be 10.
Is there any property I need to change in order to get the output I want?
0 Commenti
Risposte (1)
Fangjun Jiang
il 19 Dic 2011
I guess that is what the way stairs() is designed.
To answer your first part of the question, you probably need to do two steps.
Data=[9;9;10;9];
figure;
stairs(Data);
hold on;
plot(Data,'*');
axis([0 5 8 11]);
I am not very clear about your second part of the question. Maybe this?
Data=[9;9;10;9];
figure;
stairs([Data;Data(end)]);
hold on;
plot(Data,'*');
axis([0 5 8 11]);
2 Commenti
Fangjun Jiang
il 19 Dic 2011
I think you may have some inconsistency describing your data in your comments. I can think of a way to show the drop of y from 10 to 9 at x=8, but I don't see why x=11 comes to the picture.
%%
Data=[9;9;10;9];
x=[1;3;5;8];
figure;
stairs([x;x(end)+1],[Data;Data(end)]);
hold on;
plot(x, Data,'*');
axis([0 10 8 11]);
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!