Plotting bar graph for loop values

9 views (last 30 days)
Hari krishnan
Hari krishnan on 16 May 2019
Edited: Hari krishnan on 17 May 2019
I am trying to make a barplot of the values in vector's 'count_gn', 'count_bn', 'count_hn' and 'count_ar' as a seperate subplots. I tried using 'bar' function for the purpose. But i am not seeing any barplots.
Can anyone suggest a method to do seperate barplots for the values in the vector 'count_gn', 'count_bn', 'count_hn' and 'count_ar' ?
Any help to solve this will be appreciated.
tic
a = smoothed_final_plot_mat(1:end-2033,3:end-2);
np = (size(a,2)-1)/2; % number of particles
t = a(2:end,1);
arena_image = imread('arena_pic_gn_top.png');
subplot(1,2,1)
h1 = axes ;
cc = hsv(np);
image('XData',[0 6900],'YData',[0 5000],'CData',arena_image) ; % set your limits
set(h1,'YDir','normal');
dim = [0.79, 0.825, 0.2, 0.1];
annotation('textbox',dim);
t1 = uicontrol('Style','text','String','Select a data set.','Position',[1550 790 300 80],'FontSize',13,'HorizontalAlignment','left');
ax = gca;
ax.YDir = 'reverse';
axis([0 6900 0 5000])
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
h = zeros(1,np);
for ii = 2:25:size(a,1)
ax.Position(3) = 0.65;
k = 0;
t = a(ii,1);
count_gn(ii,1) = rowsum_for_ants_in_gdnest_matrix(ii); %#ok<SAGROW>
count_bn(ii,1) = rowsum_for_ants_in_bdnest_matrix(ii); %#ok<SAGROW>
count_hn(ii,1) = rowsum_for_ants_in_arena_except_homenest(ii); %#ok<SAGROW>
count_ar(ii,1) = rowsum_for_ants_in_field(ii); %#ok<SAGROW>
hold on
for jj = 2:2:np*2 % ant handles
x = a(ii,jj);
y = a(ii,jj+1);
k = k + 1;
h(k) = plot(x,y,'--or');
hi(k) = text(x, y, label(k), 'VerticalAlignment','bottom', 'HorizontalAlignment','right'); %#ok<SAGROW>
h2(k) = plot(a(max(1,ii-150):ii,jj), a(max(1,ii-150):ii,jj+1),'k','LineWidth',2); %#ok<SAGROW>
set(h2(k),'color',cc(k,:));
end
drawnow
pause(0.01)
delete(h)
delete(hi)
delete(h2)
disp(k)
end
toc
  2 Comments
Hari krishnan
Hari krishnan on 17 May 2019
Hi, i checked the data throughly, there is no NaN in the data. Also when i try to use 'bar' one of the axis always keeps on moving.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by