how to set y-axis as log scale?

B
bedipi4838 · Jun 24, 2025 · 372 views
Question
How to set only Y-axis to log scale in MATLAB plot?
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Sep 20, 2026

Method 1: Plot directly using semilogy

If you are generating a new 2D plot, use semilogy instead of the standard plot command:

x = 0:0.1:10;
y = exp(x);

semilogy(x, y, 'b-', 'LineWidth', 1.5);
xlabel('Linear X Axis');
ylabel('Logarithmic Y Axis');
grid on;

Method 2: Change an existing plot with YScale

If you already plotted your data using plotscatter, or bar, modify the axes property directly without re-plotting:

% Dot notation (MATLAB R2014b and newer):
ax = gca;
ax.YScale = 'log';

% Classic syntax (works in all MATLAB versions):
set(gca, 'YScale', 'log');

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

Get a Free Consultation or a Sample Assignment Review!