I have multiple time series measured in different units. I want to have a stacked plot of my data with a common x-axis. An example would be here. For illustration, here is my data.
nobs = 100;
TS1= RandomVariate[NormalDistribution[0, 1], nobs];
TS2= Accumulate[RandomVariate[NormalDistribution[0, 5], nobs]];
TS3= RandomInteger[{-10, 100}, nobs];
dates = DateRange[DatePlus[Today, Quantity[-nobs + 1, "Days"]], Today];
mytsdata = TimeSeries[#, {dates}] & /@ {TS1, TS2, TS3};
mergeddata = TimeSeriesThread[# &, mytsdata];
I can use DateListPlot
or StackedDateListPlot
to plot my data set mytsdata
or mergeddata
but none of these plots serve my interest. I created a graph using MATLAB and looks like this.
Is it possible to create a similar graph using Ma codes? Flexibility to change graph properties would add much value. The main requirement is that there has to be one and only one x-axis. Time series could be of different lengths.
Update: Here is a list of several time series with different lengths.
nobs = 100;
dates = DateRange[DatePlus[Today, Quantity[-nobs + 1, "Days"]], Today];
s1 = RandomVariate[NormalDistribution[0, 1], nobs];
s1ts = TimeSeries[s1, {dates}];
s2 = Accumulate[RandomVariate[NormalDistribution[0, 5], nobs - 25]];
s2ts = TimeSeries[s2, {dates[[26 ;;]]}];
s3 = RandomInteger[{-10, 100}, nobs - 50];
s3ts = TimeSeries[s3, {dates[[51 ;;]]}];
mergeddata2 =
TimeSeriesThread[# &, {s1ts, s2ts, s3ts},
ResamplingMethod -> Missing[]];
I want to plot mergeddata2
as follows.
Time and 2020 at the bottom of the graph are not required. Thank you in advance.
Update 2:
Incorporating Rohit's suggestion, I was able to generate my graph with the following codes:
drange = {mergeddata2["Dates"][[1]], mergeddata2["Dates"][[-1]]};
ResourceFunction["PlotGrid"][{
{DateListPlot[s1ts, Frame -> True,
PlotRange -> {drange, Automatic}]},
{DateListPlot[s2ts, Frame -> True,
PlotRange -> {drange, Automatic}]},
{DateListPlot[s3ts, Frame -> True, PlotRange -> {drange, Automatic}]}
}
]
Any suggestions for further improvement would be welcomed.