Info

1 view (last 30 days)
Yaser Khojah on 21 Nov 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
I have a script that creates a plot, but I would like to explain the axis in a better way. I have tried by adding additional information to the legend. However, it was done manually, and I need a better approach. Also, I have included some textarrow to explain the axis but I need a systemic approach since I will apply this script to different data.
I have attached the figure, but I think it can be presented better and I need a systematic approach since I need to apply this plot to different data sets.
All I want to say:
The case numbers from 1:10 belong to 15% cap while each case goes from 0 to 90% SD
The case numbers from 11:20 belong to 30% cap while each case goes from 0 to 90% SD
The case numbers from 21:30 belong to 50% cap while each case goes from 0 to 90% SD
The case numbers from 31:40 belong to 100% cap while each case goes from 0 to 90% SD
data = rand(10,100);
edges = [-200:10:40]; % bin edges
counts = histc(data, edges, 2); % specify dim 2 to act column-wise
% plot results
hf = figure;
ha = axes;
hb = bar3(edges, counts.'); % note the transpose to get the colors right
xlabel('case number')
ylabel('bins');
zlabel('count');
title('8 Fields (Demand = 8 Fields Capacity)')
legend('Case 1 = 15% Cap 0 SD' , 'Case 2 = 15% Cap 0.1 SD' ,'Case 3 = 15% Cap 0.2 SD' ,'Case 4 = 15% Cap 0.3 SD','Case 5 = 15% Cap 0.4 SD',...
'Case 6 = 15% Cap 0.5 SD', 'Case 7 = 15% Cap 0.6 SD' ,'Case 8 = 15% Cap 0.7 SD' ,'Case 9 = 15% Cap 0.8 SD','Case 10 =15% Cap 0.9 SD',...
'Case 11 = 30% Cap 0 SD' , 'Case 12 = 30% Cap 0.1 SD','Case 13 = 30% Cap 0.2 SD','Case 14 =30% Cap 0.3 SD' ,'Case 15 =30% Cap 0.4 SD',...
'Case 16 = 30% Cap 0.5 SD','Case 17 = 30% Cap 0.6 SD','Case 18 = 30% Cap 0.7 SD','Case 19 = 30% Cap 0.8 SD','Case 20 = 30% Cap 0.9 SD',...
'Case 21 = 50% Cap 0 SD' ,'Case 22 = 50% Cap 0.1 SD','Case 23 = 50% Cap 0.2 SD','Case 24 = 50% Cap 0.3 SD','Case 25 = 50% Cap 0.4 SD',...
'Case 26 = 50% Cap 0.5 SD','Case 27 = 50% Cap 0.6 SD','Case 28 = 50% Cap 0.7 SD','Case 29 = 50% Cap 0.8 SD','Case 30 = 50% Cap 0.9 SD',...
'Case 31 = 100% Cap 0 SD' ,'Case 32 = 100% Cap 0.1 SD','Case 33 = 100% Cap 0.2 SD','Case 34 = 100% Cap 0.3 SD','Case 35 = 100% Cap 0.4 SD',...
'Case 36 = 100% Cap 0.5 SD','Case 37 = 100% Cap 0.6 SD','Case 38 = 100% Cap 0.7 SD','Case 39 = 100% Cap 0.8 SD','Case 40 = 100% Cap 0.9 SD')
%%
% Create textarrow
annotation('textarrow',[0.708333333333333 0.626041666666666],...
[0.267951194184839 0.198338525441329],'String',{'50%'});
% Create textarrow
annotation('textarrow',[0.6171875 0.547395833333333],...
[0.194184839044652 0.132917964693666],'String',{'30%'});
% Create textarrow
annotation('textarrow',[0.538541666666666 0.456249999999999],...
[0.12568743509865 0.0560747663551399],'String',{'15%'});
% Create textarrow
annotation('textarrow',[0.797916666666666 0.715624999999999],...
[0.343755970924195 0.274143302180685],'String',{'100%'});