
#MATPLOTLIB SUBPLOT SCATTER CODE#
The above code means that we are setting the color of the scatter plot as red. To set the colors of a scatter plot, we need to set the argument color or simply c to the pyplot.scatter() function.įor example, take a look at the code below: plt.scatter(x, y, color = 'red') import matplotlib.pyplot as plt import matplotlib import seaborn as sns sns.setstyle ('darkgrid') matplotlib inline 15 by 15 size set for entire plots plt.figure (figsize (15,15)) Set rows variable to 2 rows 2 Set columns variable to 2, this way we will plot 2 by 2 4 plots columns 2. Setting colors to the multiple scatter plot Lets have total 4 plots in 2 rows and 2 columns.

By default, pyplot returned orange and blue. Note: Notice that the two plots in the figure above gave two different colors. Line 16: The pyplot.show() function is used, which tells pyplot to display both the scatter plots. pyplot.scatter(x,y2) is used to create a scatter plot of x and y2. Lines 12 to 13: The array y2 is created, which contains the y-coordinates for the second scatter plot. The first column has the same type of data in both rows, so it may be desirable to combine the colorbar which we do by calling lorbar with a list of axes instead of a single axes. Placing in a figure is non-trivial because room needs to be made for them. figaspect (0.5)) First subplot set up the axes for the first plot ax fig. import matplotlib.pyplot as plt from matplotlib import cm import numpy as np from 3d import gettestdata set up a figure twice as wide as it is tall fig plt. pyplot.scatter(x,y1) is used to create a scatter plot of x and y1. Colorbars indicate the quantitative extent of image data. Demonstrate including 3D plots as subplots.

Lines 8 to 9: The array y1 is created, which contains the y-coordinates for the first scatter plot.

This is how it looks like: But to completely answer the question here. going from 1.6 (rows columns) for each of the subplots. Line 5: The array x is created, containing the x-coordinates common to both plots. I hope this here helps: fig plt.figure () for i in range (6): ax fig.addsubplot (3, 2, i+1, projection '3d') The first numbers are the (total) number of rows and columns, the 3rd number is the 'index', i.e. Line 2: The numpy module is imported, which will be used to create arrays. Line 1: In matplotlib, the pyplot module is imported, which will be used to create plots.
