Creating 3D histograms
Similarly to 3D bars, we might want to create 3D histograms. These are useful for easily spotting correlation between three independent variables. They can be used to extract information from images in which the third dimension could be the intensity of a channel in the x, y space of the image under analysis.
In this recipe, you will learn how to create 3D histograms.
Getting ready
To recall, a histogram represents the number of occurrences of some value in a particular column—usually called bin. A 3D histogram, then, represents the number of occurrences in a grid. This grid is rectangular, over two variables represented by the data in the two columns.
How to do it...
For this computation we will:
- Use NumPy's help, as it has a function for computing the histogram of two variables.
- Generate
x
andy
from normal distributions, but with different parameters, to be able to distinguish the correlation in the resulting histogram. - Plot the scatter plot of the same dataset...