Professor needs specific color for bar graph, but the hex code for the color is not working.

2 ビュー (過去 30 日間)
Jack
Jack 2023 年 1 月 21 日
コメント済み: Jack 2023 年 1 月 21 日
%Everything works fine when I use the basic color commands like 'b' or 'r'.
%I just cannot get the hex code to work!
subplot (3,1,1);
bar(At_num, CI_p, 'color', "#18453B" );
title('Mol% CI Concentration');
xlabel('Atomic #');
ylabel('Mol%');
subplot (3,1,2);
bar(At_num, sw_p, 'b');
title('Mol% Seawater Concentration');
xlabel('Atomic #')
ylabel('Mol%');
subplot (3,1,3);
bar(At_num, riv_p, 'color', '#964B00');
title('Mol% Riverine Concentration');
xlabel('Atomic #')
ylabel('Mol%')
%Error message:
Error in Hines_best (line 38)
bar(At_num, CI_p, 'color', "#18453B" );

回答 (3 件)

David Hill
David Hill 2023 年 1 月 21 日
bar(1,10,'FaceColor','#18453B')%use FaceColor

Voss
Voss 2023 年 1 月 21 日
Use 'FaceColor' instead of 'color'.

Adam Danz
Adam Danz 2023 年 1 月 21 日
Color options for bar(__,color) are described in the documentation and include short names (e.g. 'r') and long names (e.g. 'red'). Instead of using optional color input, use the FaceColor name-value pair,
bar(At_num, CI_p, 'FaceColor', "#18453B");

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by