To create a scatter plot, the data points are plotted on a coordinate grid, and then a line is drawn to connect the points. Detect outliers: Scatter plots are often used to detect outliers, or data points that lie outside the general trend.For example, scatter plots can be used to show the distribution of ages in a population, the distribution of heights in a population, or the distribution of grades in a classroom. Visualize the distribution of data: Scatter plots can be used to visualize any type of data, but they are particularly useful for data that is not evenly distributed.Scatter plots can be used for the following: The X-axis can be used to represent one of the independent variables, while the Y-axis can be used to represent the other independent variables or dependent variable. These plots are created by using a set of X and Y-axis values. Scatter plots are a type of graph that shows the scatter plot for data points. Scatter plots are used in data science and statistics to show the distribution of data points, and they can be used to identify trends and patterns. Check out our entire Matplotlib playlist here.A scatter plot is a type of data visualization that is used to show the relationship between two variables. Pylenin has a dedicated Youtube playlist for Matplotlib Tutorial. Plt.scatter(iris.data, iris.data, c=iris.target) # this formatter will label the colorbar with the correct target namesįormatter = plt.FuncFormatter(lambda i, *args: iris.target_names) # The indices of the features that we are plotting Let’s plot the sepal length vs sepal width from the famous iris data set. Plotting the Iris dataset from Scikit Learn Plt.scatter(x, y, s, c="g", alpha=0.5, marker=r'$\dagger$',Ĭheck out the marker documentation of matplotlib to learn more about markers. # Fixing random state for reproducibility We will use the marker parameter to pass in necessary symbol for our plot. Let’s plot a scatter plot using the dagger symbol. You can use any symbol that fits the requirement of your graph. Scatter symbols don’t have to be circular. The above code should produce the following plot. The Matplotlib module has a number of available colormaps.Ī colormap in Matplotlib is like a list of colors, where each color has a value that ranges from 0 to 100. For this purpose, you can use a colormap. When you run this, it produces the following result.īased on the above image, it would be nice to know what each color represents. import matplotlib.pyplot as pltĪs you can see we are passing np.random.rand(N) array as our colours parameter. We can also pass in a sequence of n numbers to be mapped to colors. The above code should produce a similar graph. # You can also mention Hex codes of colors Plt.scatter(x, y1, label='Sin curve', c='green') We can set our own colour for each scatter plot by using the c or the color parameter. Let’s plot both sin and cos curves using scatter plot in the same plot. Let’s plot a simple sin curve using scatter plot.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |