Question
Hi, I want to change the FontSize, FontName and FontWeight of the axis from my graph but I only get error messages. Below you find the commands that I run and the error: SCRIPT: clear all; close all; %prepare data x = 0: pi / 100: 2 * pi; y = sin (x); h=plot(x,y); %curve properties set(h,'LineWidth',3,{'LineStyle'},{'.'}) set(h,{'Color'},{'r'}) %label properties title('TEST','FontSize',26, 'FontName','Arial', 'FontWeight','bold') xlabel('Time (seconds)','FontSize',20, 'FontName','Arial','FontWeight','bold') ylabel('Amplitude (\mum)','FontSize',20, 'FontName','Arial','FontWeight','bold') %axis properties axis([0 7 -1.2 1.2],'FontSize',26, 'FontName','Arial', 'FontWeight','bold'); legend(h,'sin(x)',3, 'BackgroundColor','b') legend('boxoff') ERROR: ??? Error using ==> axis at 183 Unknown command option FontSize Error in ==> TEST at 18 axis([0 7 -1.2 1.2],'FontSize',26, 'FontName','Arial','FontWeight','bold'); I also wanted to change the color of the legend box from white or transparent to any arbitray color. I read the documentation and used the legend function but it did not work. I hope someone know what is going wrong in these command lines
Expert Answer
Neeta Dsouza
PhD Expert
Answered Aug 20, 2026
You can do
set(gca)
to see all properties of an axis. To modify either one of them, you can do
set(gca,'Name',Value)
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related plot Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →