have you any idea, how I can bin 3 arrays to a histogram. My arrays look like
Temperature = [4, 3, 1, 4, 6, 7, 8, 3, 1]
Radius = [0, 2, 3, 4, 0, 1, 2, 10, 7]
Density = [1, 10, 2, 24, 7, 10, 21, 102, 203]
And the 1D plot should look:
Density
| X
10^2-| X
| X
10^1-|
| X
10^0-|
|___|___|___|___|___ Radius
0 3.3 6.6 10
And the 2D plot should (qualitative) look like:
Density
| 2 | |
10^2-| 11249 | |
| 233 | | Radius
10^1-| 12 | |
| 1 | |
10^0-|
|___|___|___|___|___ Temperature
0 3 5 8
So I want to bin one or two fields with python/numpy and then plot them to analyse their correspondence.
here's a bare-bones 2D version of Castro's code above. It simply plots the mean value at each x,y coordinate. This could be plotted using imshow but Castro's approach makes for a much neater scatter plot.
All the duplicated x,y points are now reduced to a unique set and their z values have been averaged:
Here it follows two functions:
hist2d_bubble
andhist3d_bubble
; that may fit for your purpose:The two figures above were created using:
Related:
Howto bin series of float values into histogram in Python?
How to correctly generate a 3d histogram using numpy or matplotlib built in functions in python?
2D histogram with Python