Question about how to put several values in one histogram
2 次查看(过去 30 天)
显示 更早的评论
I was writing the code for the rock paper scissors game, the last step is to graph the results (i.e player win times, computer win times, and draw times). The number I got for those three are 3,4,3. The histogram part I did as following:
stats_data = [user_win_time,draw,comp_win_time];
figure
stats_plot = histogram(stats_data);
% And the graph I got is attached

0 个评论
采纳的回答
Chunru
2021-9-22
You should not use histogram. You should use bar:
bar([3 4 3])
set(gca, 'XTickLabel', ["Player" "Computer" "Draw"])
更多回答(1 个)
Viranch Patel
2021-9-22
You can do something like this.
X = categorical({'user win time','draw','computer win time'});
X = reordercats(X,{'user win time','draw','computer win time'});
Y = [3 4 3];
h = bar(X,Y);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!