How to plot stacked plot horizontally parallel to each other?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I tried using horizontal stacked plot using the example given in the link as
https://www.mathworks.com/matlabcentral/fileexchange/53620-stackedplot-a-quick-way-to-plot-without-lines-overlapping
N = 4;
mu = 2*rand(1,N);
sigma = [1 0.1 10 1];%rand(1,N);
t = 1:100;
x = bsxfun(@plus,randn(100,4)*diag(sigma),mu);
subplot(1,2,1)
stackedplot(x,t)
subplot(1,2,2)
stackedplot(t,x)
But I didn't get the second plot and got an error as
Error using stackedplot (line 76)
Expected x to be a vector.
Please let me if its possible to do with stacked plots.
0 comentarios
Respuestas (1)
Narvik
el 4 de Sept. de 2024
Hi Dolly,
As per my understanding, you are facing an error while trying to use the "stackedplot" function from File Exchange.
The error arises because "stackedplot" function expects the first argument to be a vector (x-axis) and the second to be a matrix (y-axis).
To create both vertical and horizontal stacked plots, ensure inputs are correctly formatted.
Refer to the following code:
N = 4;
mu = 2 * rand(1, N);
sigma = [1 0.1 10 1];
t = 1:100;
x = bsxfun(@plus, randn(100, 4) * diag(sigma), mu);
subplot(1, 2, 1)
stackedplot(t, x) % Correct: x-axis vector, y-axis matrix
subplot(1, 2, 2)
stackedplot(t, x') % Transpose x for horizontal stacking effect
Ensure 't' is a vector and 'x' is a matrix with columns representing data series. Transposing 'x' in the second plot simulates horizontal stacking.
Hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!