Choose the ideal number of bins in hist3
4 次查看(过去 30 天)
显示 更早的评论
Dear all,
I want to plot a hist3 plot but i'm not sure which is the ideal number of bins that I would need to define.
I have two variables with 116640 x 1 size and I'm using the following line of code:
hist3([Var1, Var2],[200 200],'CDataMode','auto','EdgeColor','none');
In this case I'm using [200 x 200] number of bins but as I want to compare these results with others with different variable sizes I'm not sure how to get the ideal number of bins based on the matrix sizes.
Do you have any idea how to do this?
Thank you in advance
5 个评论
Jan
2022-12-3
What about a 2D interpolation with the smaller number of bins? This will keep the highest possible resolution for a 1-by-1 comparison.
回答(1 个)
Muskan
2023-9-4
Hi Ricardo,
I understand that you're interested in learning more about selecting the appropriate number of bins when plotting the histogram using the "hist3" function.
You can consider the following approaches to help you choose an appropriate number of bins in the “hist3” function:
Sturges' formula: One approach is to use Sturges' formula, which estimates the number of bins based on the logarithm of the number of data points. The formula is numBins = ceil(1 + log2(numPoints))
Experimentation and visualization: If the above approach do not provide satisfactory results, you can experiment with different numbers of bins and visually inspect the resulting “hist3” plots. Start with a smaller number of bins and gradually increase it to see how the histogram representation changes. Make sure to choose a number of bins that captures the desired level of detail without being too coarse or too fine.
You can further refer to the documentation of the “hist3” function:
I hope the above information helps resolve your query.
Thanks
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!