How to display a particular range of log value at x-axis?
조회 수: 6 (최근 30일)
이전 댓글 표시
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1151983/image.jpeg)
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).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1151988/image.jpeg)
Please guide me what can I add to display it like figure 1. Thank you.
댓글 수: 0
채택된 답변
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
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 Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!