How to interchange both plot and bar colour

1 回表示 (過去 30 日間)
Afsher P A
Afsher P A 2020 年 7 月 23 日
コメント済み: Afsher P A 2020 年 7 月 23 日
clear; close all; clc
month = {'apr19', 'may19', 'june19', 'july19', 'aug19', 'sept19', 'oct19', 'nov19', 'dec19', 'jan20', 'feb20', 'mar20'};
kWh = [123 139 109 89 90 96 145 167 149 123 140 180];
CUF = [17.08 18.68 15.14 11.96 12.09 13.33 19.48 23.19 20.03 16.53 19.44 24.19];
yyaxis left
p = plot(CUF);
yyaxis right
b = bar(kWh);
set(gca, 'xticklabel', month )
xlabel('Month & year')
yyaxis left
ylabel('CUF')
yyaxis right
ylabel('kWh')
p.LineWidth = 3;

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 7 月 23 日
編集済み: KALYAN ACHARJYA 2020 年 7 月 23 日
I feel you are looking for transperancy, so that both plots shoud clearly visible.
month = {'apr19', 'may19', 'june19', 'july19', 'aug19', 'sept19', 'oct19', 'nov19', 'dec19', 'jan20', 'feb20', 'mar20'};
kWh = [123 139 109 89 90 96 145 167 149 123 140 180];
CUF = [17.08 18.68 15.14 11.96 12.09 13.33 19.48 23.19 20.03 16.53 19.44 24.19];
yyaxis left
p = plot(CUF,'r');
yyaxis right
b = bar(kWh);
b.FaceAlpha = 0.5; % Change the value as per transperancy required.
set(gca, 'xticklabel', month )
xlabel('Month & year')
yyaxis left
ylabel('CUF')
yyaxis right
ylabel('kWh')
p.LineWidth = 3;
If not, then please clarify about interchange between??
Is it y axis interchange, then change yyaxis left with yaxis right or vice versa?
  1 件のコメント
Afsher P A
Afsher P A 2020 年 7 月 23 日
Yes Sir, This is also fine.
I am looking for the transparency between the plot and bar. But now axes colour doesnot match with plot and bar colours.

サインインしてコメントする。

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by