Problems creating stacked plots on MATLAB
显示 更早的评论
I would like to make a stacked plot of 3 y-axis variables, with variable 'time' on the x-axis. I have looked at the help function for stacked plot but I don't understand it. Do I need to create a table before making the stacked plot? I tried
The variables that I want on the y-axis are:
spiketimes : 1 x 100 double (it's a vector of times). I would like this to be as a raster plot.
transmit_times: 1 x 92 double (it's a vector of times). I would like this to be as a raster plot.
Probability: 1 X 10001 double. I would like a normal line graph for this
On the x-axis:
Time: 1 x 10001 double.
6 个评论
dpb
2019-3-5
What do you mean by "raster plot", precisely?
You can plot your long time vector and the probablilty that goes with it easily enough...
figure
plot(T,P)
hold on
% now the others...
The problem there is it isn't at all clear what you expect to do with the two shorter vectors of other time data...you can certainly plot at whatever time points you have on the same axis, but just what is it to be plotted against those times--we seem to be out of data.
Temi O
2019-3-5
That's just a scatter() plot with a constant value of unity at the time points. There's no need for stacked plot; by a "stacked" plot I think of area, nothing like this.
Of course you can use hold on; this type of thing is precisely what it's there for...add more stuff to the plot besides just the initial line.
Now if you're trying to plot totally disparate ranges of y values on the axis, then "Yes, Virginia, we may have a problem!" but there what you're looking for is probably two y axes. See
doc yyaxis
for details and examples.
Temi O
2019-3-7
dpb
2019-3-7
Well, "if you're ok, I'm ok!" but if you would show just what you are trying to plot with some sample data if the subplot() isn't exactly what you had in mind, it's probably not difficult to do something much more like what you envisioned originally.
回答(1 个)
Walter Roberson
2019-3-7
0 个投票
R2018b introduced stackedplot() https://www.mathworks.com/help/matlab/ref/stackedplot.html
类别
在 帮助中心 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

