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

7 visualizzazioni (ultimi 30 giorni)
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 Commenti
Himanshu Saxena
Himanshu Saxena il 14 Mag 2021
I do not see the documentation online regarding that explanation. But I have attached a screenshot of the software that clearly shows that the y-axis can be stretched without converting it into log scale.
So now I know MATLAB do not stretch the axes, I cannot plot such plot.
Adam Danz
Adam Danz il 14 Mag 2021
Modificato: Adam Danz il 14 Mag 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.

Accedi per commentare.

Risposte (1)

Adam Danz
Adam Danz il 13 Mag 2021
Modificato: Adam Danz il 13 Mag 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!

Translated by