Having error when ploting bars with filled pattern

2 visualizaciones (últimos 30 días)
nazanin tavakoli
nazanin tavakoli el 28 de Sept. de 2021
Editada: Rik el 28 de Sept. de 2021
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.

Respuestas (1)

Rik
Rik el 28 de Sept. de 2021
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.

Categorías

Más información sobre Language Fundamentals en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by