Having error when ploting bars with filled pattern

3 次查看(过去 30 天)
nazanin tavakoli
nazanin tavakoli2021-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.

标签

产品


版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by