Scatter plots with histograms
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)
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 ...