how to set y-axis as log scale?

7,030 次查看(过去 30 天)
I am plotting x-y plot using plot function. I want to set only y-axis as log scale and x-axis as linear? How to do that? I used loglog function but it scales both axis but I want only Y.


Walter Roberson
Walter Roberson 2016-4-15
编辑:MathWorks Support Team 2018-11-28
The best way to create that type of axes is to use the semilogy function. Alternatively, you can set the ‘YScale’ property on the axes:
set(gca, 'YScale', 'log')
  14 个评论
Weirong Sun
Weirong Sun 2022-5-9
good answer! It's very helpful!!!


更多回答(3 个)

Rohit Sinha
Rohit Sinha 2022-4-27
The easiest way to do this is simply use the following command instead of plot
This will plot x axis on a linear scale and y axis on a log scale. Similarly, if you want to plot x axis on log scale and y axis on a linear scale, you can use
semilogx(x,y) ;
  2 个评论
Nicholas Santiago
Nicholas Santiago 2022-11-4
yo i totally missed that I generally only read the bold stuff, thanks a ton!


Elkin Javier Cepeda Ramirez
thank you , you help me too much

Hazem Mubarak
Hazem Mubarak 2019-12-30
Thanks ;)


Community Treasure Hunt

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

Start Hunting!

Translated by