set the tick format of y axis
조회 수: 6 (최근 30일)
이전 댓글 표시
How can I set the format of the ticks of the y axis?
I want to change the upper one to the lower one, as the former is too wide in space.
댓글 수: 1
Rahul
2024년 10월 7일
dat = 0.008*rand(1, 5); % Sample random data
plot(dat)
ylim([0 0.008]) % Set any arbitrary limit
Here's a compact plot, with suitable limits:
plot(dat)
ylim([min(dat) max(dat)]) % Set compact limits
채택된 답변
Star Strider
2024년 10월 7일
x = linspace(0, 1);
y1 = sin(2*pi*x);
y2 = cos(2*pi*x)*1E-2;
figure
yyaxis left
plot(x, y1)
yyaxis right
plot(x, y2)
grid
figure
yyaxis left
plot(x, y1)
yyaxis right
plot(x, y2)
grid
Ax = gca;
Ax.YAxis(2).Exponent = -3;
Experiment with your own data. Note that you will have to specify the second y-axis to use it with your plot.
If I had your data and code, I could do this directly using them.
.
댓글 수: 0
추가 답변 (3개)
Walter Roberson
2024년 10월 7일
See ytickformat and also the Exponent property of axes; https://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-labels-of-graph-1.html#SpecifyAxisTickValuesAndLabelsExample-5
댓글 수: 0
Shivam Gothi
2024년 10월 7일
You can achieve the desired xtick format in MATLAB. In order to demonstrate this consider the code:
% Here, I will demonstrate how to express the xticks and yticks in exponent form.
x=100:100:2000;
y=100:100:2000;
plot(x,y)
ax = gca;
ax.XAxis.Exponent = 2;
ax.YAxis.Exponent = 2;
You can refer to the following link to get more information:
I hope it helps!
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!