how to edit x axis and y axis values?
조회 수: 4 (최근 30일)
이전 댓글 표시
Kaluachchi Gedara Saumya Bandara
2021년 11월 30일
댓글: Star Strider
2021년 11월 30일
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/818484/image.jpeg)
How to edit these numerical values in the form of variables? for a exapme x1, x2 ......... on the graph
댓글 수: 0
채택된 답변
Star Strider
2021년 11월 30일
x = 1:10;
y = rand(size(x));
figure
plot(x, y)
Ax = gca;
xt = Ax.XTick;
Ax.XTickLabel = compose('x%d',(1:numel(xt))); % As Numbers
yt = Ax.YTick;
Ax.YTickLabel = compose('y_{%d}',(1:numel(yt))); % As Subscripts
Another option is the NumericRuler Properties property TickLabelFormat, however I believe the Axis Properties functions are more appropriate here.
Experiment to get different results.
.
댓글 수: 2
Star Strider
2021년 11월 30일
I will do my best, however I have no idea what the desired result is.
One option is to use a legend object to identify the lines, the other is to use text objects for each point of interest.
x = 1:10;
y = rand(size(x));
figure
plot(x, y)
Ax = gca;
xt = Ax.XTick;
Ax.XTickLabel = compose('x%d',(1:numel(xt))); % As Numbers
yt = Ax.YTick;
Ax.YTickLabel = compose('y_{%d}',(1:numel(yt))); % As Subscripts
text(x(1), y(1), sprintf('$$\\ \\leftarrow x=%.2f,\\ y=%.2f$$',x(1),y(1)), 'Horiz','left', 'Vert','middle', 'Interpreter','latex')
text(x(end), y(end), sprintf('$$x=%.2f,\\ y=%.2f\\ \\rightarrow$$',x(end),y(end)), 'Horiz','right', 'Vert','middle', 'Interpreter','latex')
Make appropriate changes to get the desired result.
.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!