如何在matlab中在绘图下方添加数据表?

如何在matlab中在绘图下方添加数据表?,matlab,plot,matlab-figure,Matlab,Plot,Matlab Figure,我试图在matlab中绘制一个复合图,数据表如下。就像这张图中的一样(是的,那张是用excel制作的): 就我而言,我能画出情节,但不知道如何制作下表。这是我的密码: y = [1,4; 0,0; 0,0; 1,0; 4,5; 21,10; 13,9; 3,3; 2,NaN; 0,NaN; 0,NaN; 1,NaN]; z = [16,34; 16,17; 26,17; 27,21; 42,37; 60,45; 45,47; 37,33; 28,NaN; 14,NaN; 16,Na

我试图在matlab中绘制一个复合图,数据表如下。就像这张图中的一样(是的,那张是用excel制作的):

就我而言,我能画出情节,但不知道如何制作下表。这是我的密码:

y = [1,4; 0,0; 0,0; 1,0; 4,5; 21,10; 13,9; 3,3; 2,NaN; 0,NaN; 0,NaN; 1,NaN];
z = [16,34; 16,17; 26,17; 27,21; 42,37; 60,45; 45,47; 37,33; 28,NaN; 14,NaN; 
     16,NaN; 21,NaN];

z(z==0) = nan;

aa=max(y);
P= max(aa);

bb=max(z);
q= max(bb);

yyaxis left
a=bar(y,1,'EdgeColor','none');
ylabel('Días');
ylim([0 (P+2)]);

yyaxis right
b=plot(z);
ylim([0 (q+5)]);
ylabel('µg/m³');
b(1).LineWidth = 2;
b(1).Marker = 's';
b(1).MarkerFaceColor = [1 0.5216 0.2];
b(2).Marker = 'o';
b(2).MarkerFaceColor = [0 0.5255 0.9020];
b(2).LineWidth = 2;
b(2).Color = [0 0.4392 0.7529];

XTickLabel={'Enero' ; 'Febrero' ; 'Marzo'; 'Abril' ; 'Mayo' ; 'Junio' ; 
            'Julio' ; 'Agosto' ; 'Septiembre' ; 'Octubre' ; 'Noviembre' ; 
            'Diciembre'};
XTick=[1:12];
set(gca, 'XTick',XTick);
set(gca, 'XTickLabel', XTickLabel);
set(gca, 'XTickLabelRotation', 45);
set(gcf, 'Position', [100, 100, 1000, 350])

%Maximizar el espacio de la figura
ax = gca;
outerpos = ax.OuterPosition;
ti = ax.TightInset; 
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax.Position = [left bottom ax_width ax_height];

%%%%%% Grilla %%%%%%%
grid on

legend('Total Episodios 2017','Total Episodios 2018','Conc.Prom. Mensual 
        2017','Conc.Prom. Mensual 2018');


%%% Colores %%%%
barmap=[1 0.4 0; 0 0.4392 0.7529]; 
colormap(barmap);
如果你能给我任何帮助,我将不胜感激

figure;

% Plot first part
subplot(2,1,1);
x = [2 3 4 1 2 4 12 45];
plot(x)

% Plot table
ha = subplot(2,1,2);
pos = get(ha,'Position');
un = get(ha,'Units');
ht = uitable('Units',un,'Data',randi(100,10,3), 'Position',pos);

您可以在MATLAB中添加带有“uitable”的表格。我知道,但我试着做一个图。我加了一个例子。我认为你可以在MATLAB中创建一个像素级的表格副本,没有什么是MATLAB无法绘制的。但这并不容易。。。此外,Excel在绘图中绘制的水平网格线非常难看!我不知道你应该完全模仿这种风格:)我打赌你可以做得很相似,但完全一样,不容易。