Ticks with a single common exponent at the side
조회 수: 3 (최근 30일)
이전 댓글 표시
I would like to combine a single common exponent such as
as seen in Plot 1
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/920004/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/920009/image.png)
with a ticks based numerical order as seen in Plot 2
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/920014/image.png)
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?
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!