Create Scatter Plot with smooth Line using Python Last Updated : 15 Mar, 2021 Comments Improve Suggest changes Like Article Like Report A curve can be smoothened to reach a well approximated idea of the visualization. In this article, we will be plotting a scatter plot with the smooth line with the help of the SciPy library. To plot a smooth line scatter plot we use the following function: scipy.interpolate.make_interp_spline() from the SciPy library computes the coefficients of interpolating B-spline. By importing, this function from the Scipy library and added the parameter, It is quite easier to get the smooth line to scatter plot. Syntax: scipy.interpolate.make_interp_spline(x, y, k=3, t=None, bc_type=None, axis=0, check_finite=True) Parameters: x:-Abscissasy:-Ordinatesk:-B-spline degreet:-Knotsbc_type:-Boundary conditionsaxis:-Interpolation axischeck_finite:-Whether to check that the input arrays contain only finite numbers Return: a BSpline object of the degree k and with knots t. np.linspace() function is imported from NumPy library used to get evenly spaced numbers over a specified interval used to draw a smooth line scatter plot. Syntax: numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0) Parameters: start:-The starting value of the sequence.stop:-The end value of the sequence.num:-Number of samples to generate.endpoint:-If True, stop is the last sample.retstep:-If True, return (samples, step), where the step is the spacing between samples.dtype:-The type of the output array.axis:- The axis in the result to store the samples. Return: A array of num equally spaced samples in the closed interval Approach Import moduleCreate or load dataCreate a scatter plotCreate a smoothened curve from the points of the scatter plotDisplay plot Let us start with a sample scatter plot. Example: Python3 import numpy as np import matplotlib.pyplot as plt x = np.array([1, 2, 3, 4, 5]) y = np.array([4, 9, 1, 3, 5]) plt.scatter(x, y) plt.show() Output: Now let's visualize the scatter plot by joining points of the plot so that an uneven curve can appear i.e. without smoothening so that difference can be apparent. Example: Python3 import numpy as np import matplotlib.pyplot as plt x = np.array([1, 2, 3, 4, 5]) y = np.array([4, 9, 1, 3, 5]) plt.plot(x, y) plt.show() Output: Now, We will be looking at the same example as above with the use of np.linspace() and scipy.interpolate.make_interp_spline() function. Example: Python3 import numpy as np import matplotlib.pyplot as plt from scipy.interpolate import make_interp_spline x = np.array([1, 2, 3, 4, 5]) y = np.array([4, 9, 1, 3, 5]) xnew = np.linspace(x.min(), x.max(), 300) gfg = make_interp_spline(x, y, k=3) y_new = gfg(xnew) plt.plot(xnew, y_new) plt.show() Output: Comment More infoAdvertise with us Next Article Create Scatter Plot with smooth Line using Python D deepanshu_rustagi Follow Improve Article Tags : Python Python-matplotlib Data Visualization Practice Tags : python Similar Reads Scatter Plot with Regression Line using Altair in Python Prerequisite: Altair In this article, we are going to discuss how to plot to scatter plots with a regression line using the Altair library. Scatter Plot and Regression Line The values of two different numeric variables is represented by dots or circle in Scatter Plot. Scatter Plot is also known as a 4 min read Joining Points on Scatter plot using Smooth Lines in R A smooth line, also known as a smoothed line, is a line that is drawn through a set of data points in such a way that it represents the overall trend of the data while minimizing the effects of random fluctuations or noise. In other words, it is a way to represent a general pattern or trend in a dat 8 min read How To Make Scatter Plot with Regression Line using Seaborn in Python? In this article, we will learn how to make scatter plots with regression lines using Seaborn in Python. Let's discuss some concepts :Seaborn : Seaborn is a tremendous visualization library for statistical graphics plotting in Python. It provides beautiful default styles and color palettes to make st 2 min read Scatter plot using Plotly in Python Plotly Python is a library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. Plotly python is an interactive visualization 5 min read How to Do a Scatter Plot with Empty Circles in Python Scatter plots are a powerful visualization tool that helps in identifying relationships between two quantitative variables. In Python, libraries like Matplotlib and Seaborn provide excellent functionalities for creating scatter plots with various customizations. One common customization is to create 3 min read Like