How to display a particular range of log value at x-axis?

조회 수: 6 (최근 30일)
IMC
IMC 2022년 10월 11일
댓글: Star Strider 2022년 10월 12일
Hello everyone,
I have a simple question about x-axis display values. Here is my code:
figure
hAx=axes;
hold on
g1 = gscatter(Varaiable1, Variable2, Varaiable.L_Bin, 'm','+',7);
hAx.XScale='log';
grid on
% set(gca, 'YLim', [-38, -18], 'XLim', [0, 580], ...
% 'XScale', 'log');
set(gca, 'YDir', 'reverse');
ylim([-38 -18])
Code works totally fine. All I want is x-axis to display like figure 1 (means with three log values). In below case Variable1 is plotted at X-axis and its minimum value is 0.2.
Using the above code, here is my figure, Here again Variable1 is plotted at X-axis and its minimum value is 1.55. I understand this is causing it to be displayed from 10E1 but I want to add 3 log values like above (means 10E0 should also be dispalyed at x-axis).
Please guide me what can I add to display it like figure 1. Thank you.

채택된 답변

Star Strider
Star Strider 2022년 10월 11일
I am not certain what you want the result to be.
Perhaps using xlim would work (regardless of the axis scaling, however it may be necessary to experiment to get the result you want).
  댓글 수: 5
IMC
IMC 2022년 10월 12일
@Star Strider still didn't work.
I did this:
set(gca, 'XTick',logspace(0,3,4))
hAx.XScale='log';
Star Strider
Star Strider 2022년 10월 12일
I have no idea what the problem is.
It works here —
x = [1:0.5:9 10:1000];
y = sin(2*pi*x/250);
figure
plot(x, y)
grid
xlabel('X')
ylabel('Y')
title('Linear')
figure
plot(x, y)
grid
xlabel('X')
ylabel('Y')
title('Log')
hAx = gca;
hAx.XTick = logspace(0,3,4);
hAx.XScale = 'log';
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by