How to compress the logarithmic scale of both axes in a plot?

7 Ansichten (letzte 30 Tage)
Julian
Julian am 27 Jul. 2023
Beantwortet: dpb am 28 Jul. 2023
Hi,
how can i change the scaling of an logarithmic axis, so that the distance between , , and so on gets smaller the higher the values get?
Id like to have the axes scaled as in the following picture (both logarithmic):
The Distance on the y-Axis between 1 and 10 is bigger than the distance between 10 and 100. And the distance gets smaller the higher the values get.
Is it possible to do a plot like this.
My Code shows a graph like the one below. The exact values of the plot are not relevant i used random values in my Code to test the scaling of the axes.
My plot:
Relevant part of my Code for the plot:
%Verlauf plotten
loglog([PA(1),PE(1)],[PA(2),PE(2)]);
%Konfiguration der Achsen
axis([1,120,1,10000]);
ax =gca;
ax.XAxis.TickValues =[1 5 8 10 50 80 100]; %Angezeigte Werte der X-Achse
ax.YAxis.TickValues =[1 2 5 8 10 20 50 80 100 1000 10000]; %Angezeigte Werte der X-Achse
ax.YAxis.Scale = 'log';
grid on;
ylabel('kinematische Viskosit in mm2/s');
xlabel('Temperatur in °C');
title('Ubbelohde-Walther-Diagramm');
Thanks in advance!

Akzeptierte Antwort

dpb
dpb am 28 Jul. 2023
PA=[0.1;120];
PE=[48;20].*10.^[0 1 2 3];
semilogy(PA,log10(PE)); % look at y axis first; the 0C is tougher nut to crack...
ylim([log10(1) log10(1E5)])
ylim
ans = 1×2
0 5
yticks(log10([1 2 5 8 10 20 50 80 100 1000 10000 100000]));
yticklabels(string([1 2 5 8 10 20 50 80 100 1000 10000 100000].'));
grid on
The y axis scale at least is log(log); about the best one can do trying to fool Mother MATLAB with higher-level graphics using a log axes as a starting point is the above; you note it scales the decades as desired, but the limits and tick labels aren't what are wanted; the lower limit isn't log10(1) --> 0 even though xlim() returns [0 5] but the setting of 'YScale','log' prevents a 0 from being displayed/used. An earlier release actually doesn't return [0 5] there but
>> ylim(log10([1 1E5]))
>> ylim
ans =
0.1000 5.0000
>>
You see here the actual data lines show up correctly but the actual lower limit internal to the plot object is log10(20), apparently using the lower limit of the input data who can still be represented in log space.
The same/similar "tricks" will have to be used except with linear axes and manually labelling them as above to produce the desired result; I don't see any way to beat the MATLAB log-scaled axes into submission here.
This is one I don't know if even TecPlot™ has or not; looks like another search on the File Exchange to see if anybody has fought the good fight before and come out victorious-enough to have posted a function.
The x axis is even more of a pain because there the actual 0 isn't representable at all in log space even for the first go; you have to muck it up to even get started and ignore the infinite number of decades that exist between 10^-1 and 0.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by