Share X and Y Axes for tiled layout plot

조회 수: 82 (최근 30일)
Amanda Beatty
Amanda Beatty 2021년 3월 2일
댓글: Amanda Beatty 2021년 3월 9일
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

채택된 답변

Jan
Jan 2021년 3월 2일
  댓글 수: 1
Amanda Beatty
Amanda Beatty 2021년 3월 9일
Took me a while to figure out panel.m but in the end I got there. Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axes Appearance에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by