MATLAB Answers

Set non-uniform axis - extension of certain part of y-axis.

5 views (last 30 days)
Himanshu Saxena
Himanshu Saxena on 12 May 2021
Edited: Adam Danz on 14 May 2021
I want to extend a certain section of the y-axis in a contour plot. For e.g., 0 to 200 m and 200 to 400 m depths are extended to different extents in a plot as shown in the attached figure.
Is there a direct function to do so?
If not the extension of multiple sections of axis, 'function' for extension of one section only shall also work.
  7 Comments
Adam Danz
Adam Danz on 14 May 2021
The ODV User Guide unfortunately doesn't mention how they implement the appearance of a strechted y-axis. The tick-intervals are not linear nor do they appear to be logarithmic which are the only two options in Matlab.
To create plots that appear to have nonlinear axes that aren't logrithmic, you can stretch the data itself and apply axis ticks and tick-labels accordingly.
Note that applying a log-axis does stretch the upper portion of the data as shown in my answer, but differently than what appears in the ODV plots you shared.

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 13 May 2021
Edited: Adam Danz on 13 May 2021
The y-axis in your image is log-scaled and flipped. However, log(0) is undefined (it's -inf in matlab) so the 0-tick in the image makes me believe that the tick labels were manually placed.
Here's an example, of a log-scale on the flipped y-axis with custom ticks but without changing ticklabels.
ax = axes();
[X,Y,Z] = peaks;
contourf(X,(Y+3)*233.33,abs(Z),7)
ax.YDir = 'Reverse';
ax.YScale = 'log';
ax.YTick =[100 200 400 600 800 1000 1400];
ax.TickDir = 'out';
ylim([100 1400])
colormap(flipud(turbo(255)))

Community Treasure Hunt

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

Start Hunting!