mtex-toolbox / mtex

MTEX is a free Matlab toolbox for quantitative texture analysis. Homepage:
http://mtex-toolbox.github.io/
GNU General Public License v2.0
291 stars 186 forks source link

Suggestion about the hist.m #2105

Closed MaynotbeGarychan closed 8 months ago

MaynotbeGarychan commented 8 months ago

Hi,

Issue about: grain2d/hist https://github.com/mtex-toolbox/mtex/blob/develop/EBSDAnalysis/%40grain2d/hist.m

Background: I am trying to plot a barplot to show the distribution of grains size.

% This situation, I can change the label, title to my setting. And the label is inside the figure box.

fig = figure;
hist(grains); 
xlabel('\textbf{Grain size (radius)} [$\mu m^2 $] ','Interpreter','Latex');
ylabel('\textbf{Relative area} [$\%$]','Interpreter','Latex');
title('\textbf{Temp.} = 300$^{o}$C, \textbf{Strain rate} = 10$^{-3}$','Interpreter','Latex'); 

Screenshot from 2024-03-27 21-48-55

% However, in this situation, the label is outside the figure box.

fig = figure;
hist(grains, grains.equivalentRadius); 
xlabel('\textbf{Grain size (radius)} [$\mu m^2 $] ','Interpreter','Latex');
ylabel('\textbf{Relative area} [$\%$]','Interpreter','Latex');
title('\textbf{Temp.} = 300$^{o}$C, \textbf{Strain rate} = 10$^{-3}$','Interpreter','Latex'); 

Screenshot from 2024-03-27 21-47-25

%% It seems that when i assgn the values to the hist, the label will be out of the figure box. Then, I debug and step into the hist.m line 75 (if isNew, mtexFig.drawNow(varargin{:});end), comment it out like

min = grains.mineralList(idList); legend(min{:}) % if isNew, mtexFig.drawNow(varargin{:});end if nargout == 0, clear binId; end

Then I plot again with the hist(grains,grains.equivalentRadius);, this time when I change the label and title, they are inside the figure box. It seems this line 75 fix the figure position, or sth like this.. Screenshot from 2024-03-27 21-52-16

I don't know the exact reason of this line but it seems that it create some issues for changing the label. Just for discussion..

Best,

MaynotbeGarychan commented 8 months ago

I have solved this problem. by just using hist(grains.equivalentRadius);

This issue can be deleted...