フィルターのクリア

Plotting with string as the x axis value.

268 ビュー (過去 30 日間)
Moya Al Hayek
Moya Al Hayek 2020 年 4 月 27 日
回答済み: Image Analyst 2020 年 4 月 27 日
i'm trying to generate a graph of country by density but would like to have the country name on the x axis rather than a number. Please see my code below:
country = ["usa", "china", "india", "russia", "saudi", "germany", "italy", "spain", "canada", "syria"];
density = [35.77, 148.60, 382, 237, 205, 92.29, 95, 8.82, 15.68, 4.0753];
bar(country,density);

回答 (1 件)

Image Analyst
Image Analyst 2020 年 4 月 27 日
Try this:
hFig = figure;
country = {'usa'; 'china'; 'india'; 'russia'; 'saudi'; 'germany'; 'italy'; 'spain'; 'canada'; 'syria'};
density = [35.77, 148.60, 382, 237, 205, 92.29, 95, 8.82, 15.68, 4.0753];
bar(density);
grid on;
xticklabels(country);
hFig.WindowState = 'maximized';

カテゴリ

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

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by