Having error when ploting bars with filled pattern

조회 수: 1 (최근 30일)
nazanin tavakoli
nazanin tavakoli 2021년 9월 28일
편집: Rik 2021년 9월 28일
Hello,
I want to plot bar charts that have filled with different patterns and colors. Here is my code:
data_forest=xlsread('for.xlsx');
colors={'r','y','w','g'};
figure();
for ii=0:3
bar(ii*6+(1:6),data_forest(ii*6+(1:6)),'FaceColor',colors{ii+1})
hold on
end
hold off
legend('Summer','Fall','Winter','Spring');
set(gca,'Xtick',1:1:24,'XTickLabel',{'Evapotranspiration','Soil moisture',' Air Temperature','Total Runoff','Sensible Heat Flux','Soil Temperature',...
'Evapotranspiration','Soil moisture',' Air Temperature','Total Runoff','Sensible Heat Flux','Soil Temperature',...
'Evapotranspiration','Soil moisture',' Air Temperature','Total Runoff','Sensible Heat Flux','Soil Temperature',...
'Evapotranspiration','Soil moisture',' Air Temperature','Total Runoff','Sensible Heat Flux','Soil Temperature'});
set(gca,'XTickLabelRotation',90)
ylabel('Relative Change (%)')
grid on
ylim([-50 60])
applyhatch_plusC(gcf, '\-x.', 'rywg');
But I have received this error:
Undefined function or variable 'applyhatch_plusC'.
Error in relative_changes (line 23)
applyhatch_plusC(gcf, '\-x.', 'rywg');
Could somebody help me?
I would appreciate it if you help me.

답변 (1개)

Rik
Rik 2021년 9월 28일
Download the applyhatch_plusC function from the FileExchange here and add it to your path somewhere (or your current folder).
Note that it states it is only compatible with R2017a and later, so you might have to modify the code to make it work for R2015b.

카테고리

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

태그

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by