Plot mulitple grains datasets on a single histogramn #710
Replies: 2 comments 5 replies
-
Perhaps subplot is what you are after? Set equal limits for both y-axes and comparison should be easy. Another option would be to extract the bin centers and bin heights from histcounts and plot them as bar plots: A third option would be to use "histogram" instead of hist. The plots still overlap, but they are also transparent so can be compared relatively easily: |
Beta Was this translation helpful? Give feedback.
-
Dear all
With the `parent',axpos{i}` command you can do a lot. I do something
like this to plot multiple axes in on figure. This depends in my case of a
cell structure with the grains from different regions:
```matlab
%% Calcite grain sizes in the regions
%extract grains from from the 5 first regions different regions
n =length(mergedGrains_regions)
EQR_cc=cell(n,1);
grainsArea_cc=cell(n,1);
axpos=cell(n,1);
for i =1:n
grains_Area=mergedGrains_regions{i};
grainsArea_cc{i}=grains_Area('calcite');
EQR_cc{i}=grainsArea_cc{i}.equivalentRadius;
end
max_EQR_cc=max(cell2mat(EQR_cc));
% this is the figure
figure
nbins=50;
% you need to define number of columns and rows to make things look nice
mtexFig=newMtexFigure('nrows',n,'ncols',1,'figSize','large');mtexFig.layoutMode='user'
for i =1:n
axpos{i} =subplot(n,1,i);
nbins1=nbins*max(EQR_cc{i})/max_EQR_cc
hist(grainsArea_cc{i},EQR_cc{i},nbins1,'parent',axpos{i})
ax =gca;
ax.Legend.String=['Calcite region' num2str(i) ', n = '
num2str(length(grainsArea_cc{i}))]
end
% just to remove labels and have same max on all axes
maxsize =max(grains('calcite').equivalentRadius);
for i=1:n
mtexFig.children(i).XLim=[0 maxsize];
mtexFig.children(i).FontSize=8;
if i<n
mtexFig.children(i).XTickLabel=[];
end
end
```
man. 25. jan. 2021, 13:09 skrev nicholasbyres <[email protected]>:
… Hi Rüdiger,
Thanks for your help thus far. The following code was taken from the
hist.m file and adapted for use on a single phase.
[~,~,binIdC] = histcounts(equivalentRadius(grains_TAFR),binsC);
% compute the sum of areas belonging to the same bin
for i = 1:numel(binsC)-1
cumArea_TAFR(i) = sum(equivalentRadius(grains_TAFR(binIdC == i))) ./ sum(equivalentRadius(grains_RT));
end```
The issue here I think is the normalisation as the sum of the bins doesn't total one. I think the issue is dividing by the sum of the equivalentRadius. How can I get around this issue?
Thanks again!
Nick
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#710 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACXIUNNHWR32YQTR32FDHW3S3VNPBANCNFSM4WFDVC3A>
.
|
Beta Was this translation helpful? Give feedback.
-
Hi MTEXers,
I am trying to produce a figure that compares the grainsize distribution of several grain2d datasets on one histogram. If I use the simple method of
etc. The bars plot overlap one another. However, in some older dodumentation that I came across, for the command plotAngleDistribution (that I can't seem to find now), the bars of the multiple histogram datasets are plotted next to one another that allows for nice comparisson. Is there a simple way to do this for the hist function?
Thanks again and I hope you're all well!
Best,
Nick
Beta Was this translation helpful? Give feedback.
All reactions