web123456

MATLAB drawing bar chart

In the paper, you need to draw pictures for comparison. I feel that it is more convenient to draw matlab. First put the pictures you drew and the matlab code on it.

y=[300 311;390 425; 312 321; 250 185; 550 535; 420 432; 410 520;];
b=bar(y);
grid on;
ch = get(b,'children');
set(gca,'XTickLabel',{'0','1','2','3','4','5','6'})
set(ch,'FaceVertexCData',[1 0 1;0 0 0;])
legend('XXX-based algorithm','YY-based algorithm');
xlabel('x axis ');
ylabel('y axis');

 


Here are some relevant information about matlab bar charts that you saw online:

Record the matlab drawing bar chart.

 

Extracted from the algorithm comparison of problem classification tasks.

 

-------------------------------------------------------------------

data = [1.0, 1.0, 0.565, 0.508, 0.481, 0.745];
b = bar(data);
ch = get(b,'children');
set(ch,'FaceVertexCData',[4;2;3;1;5;6])
%set(gca,'XTickLabel',{'Sina all','Sina travel','S&S','x','mi'})
%set(gca,'XTickLabel',{'Sina all','Sina travel','S&S','STM','CHI','MI'})
set(gca,'XTickLabel',{'SVM(TF)','SVM(TFIDF)','Bayes','Rocchio(TF)','Rocchio(TFIDF)','Class Document Ranking Classification'})

axis([0 7 0.0 1.0]) 

%%%

ylabel('micro F-measure');

-------------------------------------------------------------------

 

 

--------------------------------------------------------------------------------------

 

data = [20.457, 45.578; 12.016, 22.422];
b = bar(data);

ch = get(b,'children');

set(gca,'XTickLabel',{'Training process','Testing process'})

legend('Classification algorithm based on class document ranking','Classification algorithm combined with bigram');

ylabel('Time taken (unit: seconds)');

 

--------------------------------------------------------------------------------------


  

How to set different colors for each bar in Matlab Bar graph?

How to set different colors for each bar in Matlab Bar graph?

Friday, May 15, 2009 15:39

It's easy to create Bar graphs in Matlab:

data = [3, 7, 5, 2;4, 3, 2, 9;6, 6, 1, 4];
b = bar(data);

 

 


 

 

How to make each Bar color different in Matlab?
Here is an example:


data = [3, 7, 5, 2;4, 3, 2, 9;6, 6, 1, 4];
b = bar(data);
ch = get(b,'children');
set(ch{1},'FaceVertexCData',[1;1;1;1;2;2;2;2;3;3;3;3;4;4;4;4])
set(ch{2},'FaceVertexCData',[1;1;1;1;2;2;2;2;3;3;3;3;4;4;4;4])
set(ch{3},'FaceVertexCData',[1;1;1;1;2;2;2;2;3;3;3;3;4;4;4;4])
set(ch{4},'FaceVertexCData',[1;1;1;1;2;2;2;2;3;3;3;3;4;4;4;4])

explain:
[1;1;1;1;2;2;2;2;3;3;3;3;3;4;4;4;4;4] is the color to be set. To change the color here, you can use Indexed or True Color. For details, please refer to the FaceVertexCData help document.



data = [3, 7, 5, 2];
b = bar(data);
ch = get(b,'children');
set(ch,'FaceVertexCData',[0 0 1;0 1 1;1 1 1;1 0 1;])

 


Reprinted from:/