How can I have similar left side starting point for multiple plots on tiledlayout?

I have been trying to put three plots in (3,1) style on a tiled layout. I have different resolution of data like the first one is (24,6); second one is (96,6) and third one is (288,6). Now when I try to plot them in three plots and place them in the tiled layout the beginning point on the left side do not align, so it looks odd. Can you suggest any solution for that problem. I am attaching the figure and dataset and code used for the plotting.
open sample.fig

Answers (1)

You can use xlim to set where you want each plot to begin.

4 Comments

That does not solve the problem. The problem arises because the three arrays have different number of elements and the figure canvas aren't able to plot in the same resolution. For example I have just renamed the tick labels to represent them in the same timescales and you can see that the beginning points are still not aligned in the left.
All the axes look like they begin at 0 to me, which is what I would consider "the beginning points" being aligned. Is the figure you are seeing the same as what is displayed below? If not, you should provide a screenshot.
Are you saying you want the line data shifted so that they all start at the same time? If so, that is not a problem of how the plotting works. That is a problem of the line data you've supplied.
open Sample_1.fig
As I have said the data resolution isn't the same, my issue is though the zero starts at the same alignment but the 1 is not. That's why it looks very odd. The first one the x=1 happens much later than those at second and third figure.
You need to be specifying both x and y coordinate data when you plot. If you do, the plot() command will know where you want the coordinates in axes data units, and the change in sampling resolution won't matter, e.g.,
tiledlayout(2,1)
nexttile
x=linspace(1,5,10); %low resolution
plot(x,x.^2);
xlim([0,5]); xlabel x, ylabel x^2
nexttile
x=linspace(1,5,10000); %high resolution
plot(x,x.^2);
xlim([0,5]); xlabel x, ylabel x^2

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Release

R2020a

Asked:

on 25 Aug 2023

Edited:

on 25 Aug 2023

Community Treasure Hunt

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

Start Hunting!