Stacked plot of 1D data.
stackplot(x,y) stackplot(x,y,scale) stackplot(x,y,scale,step) stackplot(x,y,scale,step,labels) stackplot(x,y,scale,step,labels,colors)
This function plots 1D slices (columns or rows) of the matrix y
stacked on top of each other, with the 1D array x
as the
x coordinate. The number of elements in x
determines whether
the columns or rows of y
are plotted.
If scale
is given, the data in the slices are rescaled as specified in scale
. The options are 'none'
to plot the data as is, 'maxabs'
for normalization to the maximum amplitude for each slice, 'int'
or 'dint'
for normalized integrals or double integrals, respectively. If an additional value is given, i.e. scale = {'maxabs',4}
, the slices are additionally multiplied by the given value after normalization (useful if the positions of the stacked lines should correspond to a specific axis, e.g. a non-linear field axis).
The rescaled slices are then plotted with a separation determined by step
, the relative step size multiplied by the maximum absolute value of the rescaled data to give the final spacing. Alternatively, a list of values at which to plot the slices can be provided (this is best used in combination with a scaling factor in scale
).
If step
is not given, a value of 1.5 is assumed.
To condense slices, decrease step
.
To space the slices further apart, increase step
.
Here is a simple example of how to display five 1024-point data in a stacked plot.
x = 1:1024; y = rand(5,1024)-0.5; stackplot(x,y);
To separate the traces more, you can use a larger relative step size
stackplot(x,y,'none',5);
To label each trace separately, provide labels
.
L = {'first','second','third','fourth','fifth'}; stackplot(x,y,'none',5,L);
Another example using a stacked plot to display orientation selection effects in ENDOR spectra recorded at different magnetic fields is shown below.
% ENDOR orientation selection in a powder clear, clf % Spin system Sys.S = 1/2; Sys.g = [2.3 2.1 2]; Sys.Nucs = '1H'; Sys.A = [3 6 2]; % MHz Sys.HStrain = [1 1 1]*220; % MHz Sys.lwEndor = 0.2; % MHz % EPR experiment settings Exp.mwFreq = 9.5; % GHz Exp.Range = [250 400]; % mT Exp.Harmonic = 0; [B,spec] = pepper(Sys,Exp); % ENDOR experiment settings ExpEndor.mwFreq = Exp.mwFreq; ExpEndor.ExciteWidth = 100; ExpEndor.Range = [8 20]; % MHz Fields = [295 310 323 332 339]; % mT for iField = 1:numel(Fields) % loop over all field values ExpEndor.Field = Fields(iField); [freq,spectra(iField,:)] = salt(Sys,ExpEndor); end % Plot EPR spectrum nexttile hold on; box on plot(B,spec,'k') cc = lines(1); xline(Fields,'Color',cc) title('EPR spectrum') % Stack plot for ENDOR spectra nexttile([2 1]) stackplot(freq,spectra,{'none',0.3},Fields,compose('%1.0f mT',Fields),cc); xlabel('frequency (MHz)'); title('ENDOR spectra');