How to get different patches (hatches) in my bar graph?

조회 수: 8 (최근 30일)
sanjay Krishnamurthy
sanjay Krishnamurthy 2022년 3월 25일
답변: Chunru 2022년 3월 25일
%% Below is my code, I wanted to get the different patch style for my first (AR,WQ,AC,FC) 4 bar lines. I tried several options and it did not work, can someone help me here.
%% I want to retain the color code too
name = {'AR','WQ','AC','FC','WQ+S','AC+S','FC+S'};
X = [1:7];
%Y = [AreaPk_AR AreaPk_WQ AreaPk_AC AreaPk_FC AreaPk_WQS AreaPk_ACS AreaPk_FCS];
Y = [0.1167 0.01998 0.01872 0.0410 0.4390 0.2141 0.6627]
b = bar(X,Y,0.5)
set(gca,'xticklabels',name)
ylabel('Area below the peak in ')
hold on
b1 = set(bar(X(1), Y(1),0.5,'FaceColor','black'));
hold on
set(bar(X(2), Y(2),0.5,'FaceColor','#0072BD')); %WQ
hold on
set(bar(X(3), Y(3),0.5,'FaceColor','#D95319')); %AC
hold on
set(bar(X(4), Y(4),0.5,'FaceColor','#7E2F8E')); %FC
hold on
set(bar(X(5), Y(5),0.5,'FaceColor','#0072BD')); %WQS
hold on
set(bar(X(6), Y(6),0.5,'FaceColor','#D95319')); %ACS
hold on
set(bar(X(7), Y(7),0.5,'FaceColor','#7E2F8E')); %FCS

답변 (1개)

Chunru
Chunru 2022년 3월 25일

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by