Share X and Y Axes for tiled layout plot
150 views (last 30 days)
Show older comments
I have a tiled layout where each row has identical y-axes and each column has identical x axes. The labels are taking up space so I'd like to remove the duplicate axes numbers so I just have y-axis labels on the far left only, and x-axis labels on the bottom plots only.
Additionally, I'd love to have my y-label be separate for each row. Right now it's one label that I just put a bunch of spaces in between to space out the "Temperature" label and the "Delta from Baseline" label. If they could each be centered on their own row that would be great. I've been searching but I can't figure it out.
My code:
groupCount = length(groupNames); %count how many group there are
charts = tiledlayout(2,groupCount,'TileSpacing','Compact', 'Padding', 'compact'); %create figure for plotting
xlabel(charts,'Days on Test')
ylabel(charts, 'Delta from Baseline (pA) Temperature (C)')
for i = 1:length(data)
%Plot by group
groupPlotIdx(i) = find(strcmp(groupNames, data_analyzed(i).group)); %sort them all into groups
figure(1)
%temperature plot
tempPlot = nexttile(groupPlotIdx(i));
plot(data(i).temperatureTimestamp, data(i).temperature)
title(num2str(cell2mat(groupNames(groupPlotIdx(i)))))
tempPlot.YLim = [35 44]; %set y axis limits
hold on
plot( data(i).temperatureTimestamp(startIdx),data(i).temperature(startIdx), '^k', 'MarkerFaceColor', 'k' ); %plot start point
hold on
%delta from baseline plot
signalPlot = nexttile(groupPlotIdx(i)+groupCount);
yline(0, '-k', 'LineWidth', 0.75);
plot(data(i).signalTimestamp, data_analyzed(i).signalNormalized)
signalPlot.YLim = [-200 100]; %set y axis limits
signalPlot.YTick = -200:50:100; %tick marks every 50pA
signalPlot.YMinorTick = 'on';
signalPlot.YGrid = 'on'; %turn on grid
end
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!