We can combine a simple scatter plot with histograms for each axis. These kinds of plots help us see the distribution of the values of each axis.
Let's generate some randomly distributed data for the two axes:
>>> from matplotlib.ticker import NullFormatter >>> # the random data >>> x = np.random.randn(1000) >>> y = np.random.randn(1000)
A NullFormatter
object is created, which will be used for eliminating the x and y labels of the histograms:
>>> nullfmt = NullFormatter() # no labels
The following code defines the size, height, and width of the scatter and histogram plots:
>>> # definitions for the axes >>> left, width = 0.1, 0.65 >>> bottom, height = 0.1, 0.65 >>> bottom_h = left_h = left+width+0.02 >>> rect_scatter = [left, bottom, width, height] >>> rect_histx = [left, bottom_h, width, 0.2] >>> rect_histy = [left_h, bottom, 0.2, height]
Once...