フィルターのクリア

How to save a MATLAB created by bar function in a right size .pdf?

1 回表示 (過去 30 日間)
Rahim Rahim
Rahim Rahim 2021 年 4 月 20 日
回答済み: Rahim Rahim 2021 年 4 月 20 日
I save a graphic as .pdf format, but matlab will produce an A4 size to put this small picture in the middle of this A4 size pdf. The problem comes when I import them into my LaTeX file, i only need the picture size, not the whole A4 pdf size. Could anyone tell how to solve this problem?
This is my code
function DisplayGeneral(Conversational,Background,...
Interactive,Streaming,...
NameFunctions)
max1= max(Conversational(1,:));
max2=max(Background(1,:));
max3=max(Interactive(1,:));
max4=max(Streaming(1,:));
MAX=max(max1, max(max2,max(max3,max4)) );
% This will produce 4 groups of 3 different colored bars
x = [1 2 3 4];
y = [Conversational ;Background; Interactive ;Streaming];
Bar = bar(x,y); % h will have 3 handles, one for each color of bars
% set 3 display names for the 3 handles
%xtips1 = Bar(1).XEndPoints;
NameFunctions=cellstr(NameFunctions);
set(Bar, {'DisplayName'}, NameFunctions');
% Legend will show names for each color
legend() ;
somenames={'Conversational','Background','Interactive','Streaming'};
set(gca,'xticklabel',somenames)
set(gcf, 'Position', [100, 100, 800, 450]);
ylabel('Rank Reversal Ratio [%]')
xlabel('Traffic classes')
ylim([0 MAX+30]);
%text(xtips1,ytips1,string( ) ,'HorizontalAlignment','center','VerticalAlignment','bottom')
opts = {'VerticalAlign','middle', 'HorizontalAlign','left', ...
'FontSize',8, 'Rotation',90};
%title('')
for k1 = 1:size(Conversational,2)
ctr(k1,:) = bsxfun(@plus, Bar(k1).XData, Bar(k1).XOffset'); % Note: ‘XOffset’ Is An Undocumented Feature, This Selects The ‘bar’ Centres
ydt(k1,:) = Bar(k1).YData; % Individual Bar Heights
end
for k1 = 1:size(ctr,2)
format short
text(ctr(:,k1), ydt(:,k1), sprintfc('%.1f',ydt(:,k1)), 'HorizontalAlignment','center', 'VerticalAlignment','bottom')
end
end

回答 (1 件)

Rahim Rahim
Rahim Rahim 2021 年 4 月 20 日
I need your help

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by