How can I plot xticklabels from a 3-column matrix?
3 次查看(过去 30 天)
显示 更早的评论
Hello again,
So I asked a quesiton previously and it got answered but I realized that really it was the wrong question because I couldn't do what I wanted to how in the way I intented. My bad!
Imagine I have a 3-column numeric matrix A:
A =
[10 20 30;
30 40 50;
50 60 70;
80 90 100;
110 120 130;
140 150 160];
I have a plot, lets say it is a line plot of a vector V of 6 elments:
V = [3 4 2 5 4 5];
I want the x-ticks of this plot to be the rows of A.
E.g. the x-tick of value of V(1) = 3, should be '10 20 30', and the x-tick value of V(2) = 4 should be '30 40 50'.
If possible, it would be amazing if each of these threes values are displayed on three seperate lines:
So
'10
20
30'
Instead of '10 20 30' (for the x-tick value of V(1) = 3). This would improve readability for cases where V is very long.
Thank you!
0 个评论
采纳的回答
DGM
2021-12-1
You can try something like Adam's answer here:
V = [3 4 2 5 4 5];
A =[10 20 30;
30 40 50;
50 60 70;
80 90 100;
110 120 130;
140 150 160];
plot(V)
labels = compose('%d',A.');
labels = sprintf('%s\\newline%s\\newline%s\n', labels{:});
hax = gca;
hax.XTick = 1:numel(V);
hax.XTickLabels = labels;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!