bar chart 2 data sets side by side with different axis
1 回表示 (過去 30 日間)
古いコメントを表示
hold on;
yyaxis left
bar(T3_blocked)
yyaxis right
bar(S1_free)
set(gca, 'XTickLabel',name)
set(gca, 'XTick',1:length(name))
set(gca, 'XTickLabelRotation',45)
hold off;
produces:
how can I have the two bars for each material side by side, so the y-axes are both increasing in the same direction (up)?
0 件のコメント
採用された回答
Voss
2022 年 1 月 29 日
編集済み: Voss
2022 年 1 月 29 日
You can do that by using abs(S1_free) and specifying the locations and widths of the bars:
T3_blocked = [2 1.95 1.5 0.1 1.4]*1e-7;
S1_free = -[1.4 1.4 1 2.9 2]*1e-4;
name = strcat('PZT-',num2cell('A':'E'));
n = numel(name);
hold on;
yyaxis left
bar((1:n)-0.2,T3_blocked,0.4); % locations, heights, width
yyaxis right
bar((1:n)+0.2,abs(S1_free),0.4); % locations, heights, width
set(gca, 'XTickLabel',name)
set(gca, 'XTick',1:length(name))
set(gca, 'XTickLabelRotation',45)
hold off;
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!