필터 지우기
필터 지우기

How to change the fontsize of labels not axsis.

조회 수: 7 (최근 30일)
ryunosuke tazawa
ryunosuke tazawa 2021년 11월 1일
댓글: Voss 2021년 11월 2일
I want to change the fontsize of labels of x and y.
But if I change the font size of the label, the size of the numerical value on the axis will also change.
Is there good way?
Theta_Theory = linspace(-3.14, -4.71, 100);
Velocity_Theory = linspace(-100,0,100);
x1 = sin(Theta_Theory);
y1 = -cos(Theta_Theory);
T = sqrt(2*abs(y1)/9.8);
z = x1 + abs(Velocity_Theory).*T.';
z = -abs(z - target);
x = Theta_Theory;
y = Velocity_Theory;
minx = min(x);
maxx = max(x);
miny = min(y);
maxy = max(y);
meanValue = mean(z);
heatMapImage = meanValue .* zeros(100,100);
for k = 1 :100
column = round( (x(k) - minx) * 100 / (maxx-minx) ) + 1;
row = round( (y(k) - miny) * 100 / (maxy-miny) ) + 1;
heatMapImage(row, column) = z(k);
end
figure(1)
hh = heatmap(x,y,z,'Fontname','Times New Roman','ColorbarVisible', 'on','GridVisible','off');
h = gca;
%.xlabel('Angular[rad]');
%h.ylabel('Angular Velocity[m]');
h.FontSize = 8; % here is problem.
h.FontName = 'Times New Roman';
h.xlabel('Angular(rad)');
h.ylabel('AngularVelocity[m/s^2]');
colormap hot

답변 (2개)

Voss
Voss 2021년 11월 1일
Try replacing those four lines of code with the following:
h.FontName = 'Times New Roman';
h.XLabel.String = 'Angular(rad)';
h.YLabel.String = 'AngularVelocity[m/s^2]';
h.XLabel.FontSize = 8;
h.YLabel.FontSize = 8;
  댓글 수: 2
ryunosuke tazawa
ryunosuke tazawa 2021년 11월 2일
The error happed.
Dot indexes are not supported for variables of this type and assignments cannot be made.
Should I do?
Voss
Voss 2021년 11월 2일
make sure h is still your axes when those lines run

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


Jan
Jan 2021년 11월 1일
h = gca;
h.FontSize = 8; % here is problem.
This changes the font size of the complete axes object. If you want to change the font size of the x-label only, do not touch the font size of the axes, but of the XLabel:
axesH = axes;
plot(axesH, 1:10);
axesH.XLabel.String = 'X label';
axesH.XLabel.FontSize = 20;

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by