How to plot string on X-axes and number in Y-axes in figure?
308 次查看(过去 30 天)
显示 更早的评论
Hello,
I want plot my RMSE data value on the y-axes and the string the value on the x-axes for my research work paper.
I need to set legend also. I tried following code but its not working
Following is the sample code
x_axes=['Case-1','Case-2','Case-3','Case-4']
Y_axes=[4,5,6,7]
figure('name','sample','PaperSize',[3.3 2.71],'NumberTitle','off');
plot(Y_axes)
set(gca,'xticklabel',x_axes.')
0 个评论
采纳的回答
Steven Lord
2021-1-8
This doesn't do what you think it does.
x_axes=['Case-1','Case-2','Case-3','Case-4']
Instead use a string array or a cell array each element of which is a char vector.
x_axes1=["Case-1","Case-2","Case-3","Case-4"]
x_axes2={'Case-1','Case-2','Case-3','Case-4'}
But plot is not defined for either string or cellstr variables. You could instead convert that text data to categorical and make a categorical plot.
C = categorical(x_axes1)
plot(C, (1:4).^2, 'ko-')
4 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!