MATLAB Answers

subplot log-scale set range

28 views (last 30 days)
RuiQi on 10 Aug 2017
Edited: John BG on 10 Aug 2017
I have a plot that looks compressed because one or some of the plots are too far away.
I want to compress it so it look nicer. I use set(gca, 'YScale', 'log'); on all the subplot initialization but the result still look ugly.
How do I
1. Do a proper log plot ?
2. Smartly compress the axis range (first figure) so the plot take up the entire graph ?


Akira Agata
Akira Agata on 10 Aug 2017
What do you mean by 'proper log plot' ? Anyway, I think the solution for this would be to adjust YLim for each plot.
José-Luis on 10 Aug 2017
I don't get it. What are you trying to achieve? Your plots look fine to me.
There are limits to how much you can massage your data to make them look how you want.
If your plots are related, it might be misleading to have different transforms applied to all of them.

Sign in to comment.

Answers (2)

dpb on 10 Aug 2017
You can still use non-decade values for ylim even on log axes, by default the logic for data that spans a couple of decades will be as you see to use even decade values. ylim([0.05 1]) or in that neighborhood might help on the left one but the linear axes look "better" to me than the log for all three, personally.
What would help more than either log or y-axes scaling on these in my opinion would be to expand the x-axes scale some -- start with xlim([0 700]) or xlim([100 700]) and adjust from there...


Sign in to comment.

John BG
John BG on 10 Aug 2017
Edited: John BG on 10 Aug 2017
Hi RuiQi
compress the data on Y axis by increasing the Y span of axis handle
Let's say you have the following points, just test points randomly generated earlier on
x =[7 9 -8 9 3 -8 -5 1 10 10 -7 10]
y =[10 0 6 -8 -2 9 6 10 3 -10 7 9]
plot(x,y);grid on
capture the axis handle
h1 =
Axes with properties:
XLim: [-8 10]
YLim: [-10 10]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0.1300 0.1100 0.7750 0.8150]
Units: 'normalized'
increase Y axis span
h1.YLim=[-30 10]
Increase the lower limit of the Y axis until all the curves are close enough for presentation.
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG


Sign in to comment.


Community Treasure Hunt

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

Start Hunting!