How to change the fontsize of labels not axsis.
7 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
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 个评论
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;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!