Set Square root axis scale
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nuno Fahla
el 5 de Feb. de 2021
Comentada: Star Strider
el 5 de Feb. de 2021
How can I set the y axis scale to the square root as this graph here? I tried set(gca, 'yscale', 'lsqrt') but it didnt work!!!
thanks in advance

0 comentarios
Respuesta aceptada
Star Strider
el 5 de Feb. de 2021
Experiment with this approach to get the result you want:
x = 0:100;
y = rand(size(x))*512;
figure
plot(x, y, '.')
grid
yt = [0 2.^(0:ceil(log2(max(y))))];
set(gca, 'YTick',yt, 'YScale','log')
.
2 comentarios
Star Strider
el 5 de Feb. de 2021
As always, my pleasure!
I am not certain how to interpret the rest of your Comment. If you want to limit the y-axis to the next power of 2 that is greater than the maximum value of your data, the nextpow2 function can likely do what you want. (I did not use it in my posted code because I was not certain what the eventual desired result would be.)
Also, experiment with omitting (turning off) the minor ticks and associated minor grid lines, if you do not want them to be displayed:
set(gca, 'YTick',yt, 'YScale','log', 'YMinorTick','off', 'YMinorGrid','off')
.
Más respuestas (0)
Ver también
Categorías
Más información sobre Axes Appearance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
