xlabel not showing in subplot
10 次查看(过去 30 天)
显示 更早的评论
%parameters for figure and panel size
plotheight=10.5;
plotwidth=31.5;
subplotsx=3;
subplotsy=1;
leftedge=2.5;
rightedge=6;
topedge=1.5;
bottomedge=1.5;
spacex=0.25;
spacey=0.25;
fontsize=5;
sub_pos=subplot_pos(plotwidth,plotheight, ...
leftedge,rightedge,bottomedge,topedge, ...
subplotsx,subplotsy,spacex,spacey);
%setting the Matlab figure
f=figure('visible','on')
clf(f);
set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperSize', [plotwidth plotheight]);
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperPosition', [0 0 plotwidth plotheight]);
CM=[0,0.4470,0.7410; 0.8500,0.3250,0.0980; 0.9290,0.6940,0.1250; ...
0.4940,0.1840,0.5560; 0.4660,0.6740,0.1880];
%this is the data
data=xlsread('C:\Users\Madhur Mangalam\Google Drive\Write Ups\Papers\Ongoing\Mangalam_et_al._2018_Journal_of_Experimental_Biology\Fig6');
%loop to create plots
for i=1:subplotsx
for ii=1:subplotsy
ax=axes('position',sub_pos{i,ii},'Box','on','Layer','top');
for v=1:1
for h=1:3
if i==h & ii==v;
plot(data((h*4-3):(h*4),1:5),'o-',...
'LineWidth',2.5,'MarkerFaceColor','auto');
colormap(CM);
if i==1
axis([0.5 4.5 0 5]);
ax.TickLength=[0.025 0.025];
ax.FontName='Verdana'; ax.FontSize=12;
ax.XTick=[1,2,3,4]; ax.XTickLabel={'Q1','Q2','Q3','Q4'};
ax.YTick=[1.0, 2.0, 3.0, 4.0];
ax.YTickLabel={'1.0','2.0','3.0','4.0'};
ylabel('CV/UV');
ax.YGrid='on'; ax.GridAlpha=[0.25]; ax.LineWidth=1.5;
text(0.05,0.91,['\bf','A'],'FontName','Verdana', ...
'FontSize',18,'Units','Normalized');
end
if i==2
axis([0.5 4.5 0 5]);
ax.TickLength=[0.025 0.025];
ax.FontName='Verdana'; ax.FontSize=12;
ax.XTick=[1,2,3,4]; ax.XTickLabel={'Q1','Q2','Q3','Q4'};
ax.YTick=[1.0, 2.0, 3.0, 4.0]; set(ax,'yTickLabel',[])
xlabel=('Quartile');
ax.YGrid='on'; ax.GridAlpha=[0.25]; ax.LineWidth=1.5;
text(0.05,0.91,['\bf','B'],'FontName','Verdana','FontSize',18,'Units','Normalized');
end
if i==3
axis([0.5 4.5 0 5]);
ax.TickLength=[0.025 0.025];
ax.FontName='Verdana'; ax.FontSize=12;
ax.XTick=[1,2,3,4]; ax.XTickLabel={'Q1','Q2','Q3','Q4'};
ax.YTick=[1.0, 2.0, 3.0, 4.0]; set(ax,'yTickLabel',[])
ax.YGrid='on'; ax.GridAlpha=[0.25]; ax.LineWidth=1.5;
text(0.05,0.91,['\bf','C'],'FontName','Verdana','FontSize',18,'Units','Normalized');
end
end
end
end
end
end
lgd=legend({'Chuchu - 2.1 kg', 'Dita - 2.1 kg','Presenete - 2.2 kg','Teimoso - 3.6 kg','Monsinho - 4.3 kg'},'Units','Centimeters','Position',[13.35 5.55 0 0]);
legend('boxoff');
lgd.FontName='Verdana'; lgd.FontSize=12;
print('C:\Users\Madhur Mangalam\Google Drive\Write Ups\Papers\Ongoing\Mangalam_et_al._2018_Journal_of_Experimental_Biology\Fig6','-dtiff','-r600');
2 个评论
Image Analyst
2017-7-16
We have a different problem:
Undefined function or variable 'subplot_pos'.
Error in test (line 14)
sub_pos=subplot_pos(plotwidth,plotheight,leftedge,rightedge,bottomedge,topedge,subplotsx,subplotsy,spacex,spacey);
Please give us code that runs and illustrates the plot without an x label.
dpb
2017-7-16
编辑:dpb
2017-7-17
And immediately after the above problem will be we don't have the input file...
I suspect all that's needed is to remove the specific positions from the axes calls and use subplot and let it default to positions. You're probably just not leaving sufficient room for labels to show or are writing over the area the label requires to be visible with later calls to axes with fixed positions.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!