How can I plot a bar char from an excel file?

32 ビュー (過去 30 日間)
Behrad Ze
Behrad Ze 2023 年 1 月 28 日
回答済み: Simon Chan 2023 年 1 月 28 日
I wan to plot a bar chart like the attached picture from the attached excel file sample. The problem is that I can not use the first column as ticks. It is shown by numbers.I tried some other techniques but it did not work since all the letter were not shown on the plot. I would be thankful if someone could help me. Thanks!
csvfiles = dir('*.csv');
for file = csvfiles'
T = readtable(file.name) ;
A = table2array(T(2:end,2:end)) ;
l = T.(1) ;
bar(A)
end

採用された回答

Simon Chan
Simon Chan 2023 年 1 月 28 日
Try the following:
T = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1276650/Sample.csv');
X = categorical(T.Var1); % Convert to categorical
Y = table2array(T(:,2:3));
bar(X,Y)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by