Share X and Y Axes for tiled layout plot
105 次查看(过去 30 天)
显示 更早的评论
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/536661/image.png)
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 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!