How can I change the font size of the current axis?
조회 수: 1,084 (최근 30일)
이전 댓글 표시
How can I change the font size of the axes of the current graph without creating new axes? For example, if we have this plot already, how can I change the font size?
x = rand(10,10);
y = rand(10,10);
plot(x,y)
댓글 수: 0
채택된 답변
Matt Fig
2022년 4월 28일
편집: MathWorks Support Team
2022년 4월 28일
To change the font size, set the FontSize property on the axes object after plotting. For example:
x = rand(10,10);
y = rand(10,10);
plot(x,y);
set(gca,”FontSize”,20)
Starting in R2022a, you can use the “fontsize” function to change the font size for any graphics object that has text associated with it. In this case, pass the axes object to the “fontsize” function followed by the desired font size in points. For example:
fontsize(gca,20)
You can also change the font name using the “fontname” function. The font you specify must be installed on your system. For example, change the font of the current axes to Courier:
fontname(gca,"Courier")
댓글 수: 3
추가 답변 (2개)
Image Analyst
2022년 5월 16일
See attached demo to see how you can independently change a wide variety of things in your axes.
댓글 수: 3
Image Analyst
2022년 10월 26일
Attach your script and say what you want each y axis to look like (fontsize, color, tickmarks, or whatever).
Rhythm Analyst
2022년 10월 26일
Solved the issue; I was using ax=gca; for both 'yyaxis left' and 'yyaxis right'. Fix was to have ax1 for left yaxis and ax2 for right yaxis; as far as I can tell thats what fixed it anyway...
Thanks for the response.
Sulaymon Eshkabilov
2023년 1월 20일
There is one minor correction with one of the otptions proposed by @Mat Fig using fontsize() the unit has to be specified:
x = 1:5;
y = randi(5,1,5);
plot(x,y)
fontsize(gca, 15,'points') % 'pixels', 'centimeters', 'inches'
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Labels and Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!