Ticks with a single common exponent at the side

조회 수: 3 (최근 30일)
Filip Tsai
Filip Tsai 2022년 3월 9일
답변: Ayush 2023년 10월 9일
I would like to combine a single common exponent such as as seen in Plot 1
with a ticks based numerical order as seen in Plot 2
Here, a to n are arbitrary numbers.
I have tried
ax=gca;
ax.XAxis.Exponent=-2;
with Plot 2, but as it did not work I was wondering if there is any other command I can use when using ticks?

답변 (1개)

Ayush
Ayush 2023년 10월 9일
Hi Filip,
I understand that you want to mark all the elements in your plot on the x-axis.
To do so, you can use the “xticks” function which will mark all the elements in your plot on x-axis.
You can refer to the below code for better understanding:
% Generate the data points
x = (1:14)*10^-2; % X-axis values
y = ones(1,14); % Y-axis values
% Plot the data
figure
plot(x, y, 'o-')
% % Set ticks for every element on the x-axis
xticks(x)
xlim([0 15*10^-2])
ax=gca;
ax.XAxis.Exponent=-2;
yticks([0 0.5 1 1.5 2])
% Add labels and title
xlabel('X-axis')
ylabel('Y-axis')
title('Plot with Ticks for Every Element on X-axis')
For more information on the “xticks” function and its usage, please refer to the following documentation link:
Hope this helps!
Regards,
Ayush.

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by