[Scilab-users] Histogram plot

Claus Futtrup cfuttrup at gmail.com
Sat Mar 18 16:04:04 CET 2017


Hi Samuel

This works. Thanks. Now I understand what normalization does - and that 
it's default = true. :-)

What about the fact that I'd like not only to outline the bars, but I 
like the bars to be colored solid grey? (The help pages show no examples 
of this).

Best regards,
Claus

On 18-03-2017 15:52, Samuel Gougeon wrote:
> Hello Claus,
> Have you tried the "normalization=%f" histplot() option?
> SG
>
> Le 18/03/2017 à 15:47, Claus Futtrup a écrit :
>>
>> Dear Scilab users
>>
>> I've tried to use histplot, but I probably just don't understand what 
>> it does or what it is supposed to do. I hope you can help me do this 
>> in a smarter way. Here's to code which does the correct stuff - but 
>> as you can see, I have to "manually" count what goes into each 
>> histogram category - and afterwards I also have to manually "paint" 
>> the histplot. It's rather complicated for being such a simple task.
>>
>> // sample.sce
>>
>> Bl = [
>>
>> 7.007 7.065 7.047 6.999 6.999 7.025 6.998 7.075 7.035 ..
>>
>> 7.037 7.071 7.031 7.069 7.032 7.02 7.047 7.025 7.026 ];
>>
>> avgbl = mean(Bl);
>>
>> [nearest,i] = min(abs(Bl-avgbl)); // 'nearest'is unimportant, we need i
>>
>> nearest = Bl(i); // This is our 'Master'for the BIAS study
>>
>> Bl_diff = Bl - nearest;
>>
>> minBl_diff = floor(100*min(Bl_diff))/100 - 0.005;
>>
>> maxBl_diff = ceil(100*max(Bl_diff))/100 + 0.005;
>>
>> bins = (maxBl_diff - minBl_diff)*100; // we create 9 bins
>>
>> dividers = linspace(minBl_diff,maxBl_diff,bins+1); // 10 dividers
>>
>> bin_vec(1) = sum(Bl_diff < dividers(2)); // start initialize bin_vec
>>
>> for i=2:bins do
>>
>> bin_vec(i) = sum(Bl_diff < dividers(i+1)) - sum(Bl_diff < dividers(i))
>>
>> end // bin_vec contains the correct frequency count
>>
>> scf();
>>
>> drawlater();
>>
>> // histplot(dividers,Bl_diff,style=2); // WRONG FREQUENCY COUNT
>>
>> for i=1:bins do
>>
>> xi = (dividers(i+1) + dividers(i))/2; // middle of bin container
>>
>> xlo = xi - 0.004;
>>
>> xhi = xi + 0.004;
>>
>> plot([xlo xlo],[0 bin_vec(i)],'-k');
>>
>> plot([xlo xhi],[bin_vec(i) bin_vec(i)],'-k');
>>
>> plot([xhi xhi],[0 bin_vec(i)],'-k');
>>
>> xfpoly([xlo xlo xhi xhi xlo],[0 bin_vec(i) bin_vec(i) 0 
>> 0],color("grey"));
>>
>> end
>>
>> xtitle("","Bias study, $Bl$ - mean($Bl$)","Count");
>>
>> drawnow();
>>
>> Best regards,
>>
>> Claus
>>
>>
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170318/cd8467b6/attachment.htm>


More information about the users mailing list