Javatpoint Logo
Javatpoint Logo

Scatter() plot pandas in Python

A data visualization method that displays the relationship between two numerical variables is called a scatter plot. In Python, there is a class named DataFrame that can be used to plot to scatter plots using pandas, and this class's member is called plot. By using the scatter() function on the plot component, a pandas DataFrame plot is drawn between two variables or two columns.

Utilizing a Pandas DataFrame for a scatter plot

  • The plot is a member of the Python pandas DataFrame class.
  • Drawing a scatter plot between two specified columns of a pandas DataFrame requires calling the scatter() function on the plot component.
  • Multiple columns are possible in a pandas DataFrame.
  • The scatter() method's X and Y inputs can be any two columns.

Syntax

Here, the syntax shows how to write code for the scatter() method:

The following are the syntax parameters for the scatter() method:

  • X_axis value - An array holding the scatter plot's x-axis data.
  • Y_ axis value - a data array for the y-axis.
  • S stands for the marker's size (can be scalar or array of size equal to the size of x or y)
  • c- the order of the markers' colors

Examples

Here are various examples of scatter plots of pandas with different parameters. We can see the many scatter plots with a given size, color, and other functions.

Example1: the following example shows a scatter plot using the pandas. We can see the plot values in the x and y-axis position with essential tuples.

Output

The following image shows a scatter plot of the pandas.

Scatter() plot pandas in Python

Example2: the following example shows a scatter plot using the pandas dataframe. Here, we use string and numerical values for scatter plots.

Output

The following image shows a scatter plot with value in Python.

Scatter() plot pandas in Python

Example3: the following example shows a scatter plot using Python. Here, we use color to the tuple of the scatter plot.

Output

The following image shows a scatter plot with value in Python.

Scatter() plot pandas in Python

Example4: the following example shows a scatter plot using Python. Here, we use the required size of the tuple of the scatter plot.

Output

The following image shows a scatter plot with value in Python.

Scatter() plot pandas in Python

Example5: the following example shows a scatter plot using Python. Here, we use the required size of the tuple of the scatter plot with edge color.

Output

The following image shows a scatter plot with value in Python.

Scatter() plot pandas in Python

Example6: the following example shows a scatter plot using Python. Here, we use the required size of the tuple of the scatter plot with edge color and line width.

Output

The following image shows a scatter plot with value in Python.

Scatter() plot pandas in Python

Example7: the following example shows a scatter plot using Python. Here, we use the required size of the tuple of the scatter plot with a different color.

Output

The following image shows a scatter plot with value in Python.

Scatter() plot pandas in Python

Example8: the following example shows a scatter plot using Python. Here, we use the required size of the tuple of the scatter plot with different colors and sizes

Output

The following image shows a scatter plot with value in Python.

Scatter() plot pandas in Python

Example9: the following example shows a scatter plot using Python. Here, we use two bar-type scatter plots in different colors for comparison purposes.

Output

The following image shows a scatter plot with value in Python.

Scatter() plot pandas in Python

Conclusion

The scatter plot in pandas shows multiple types of graphs using python language. Here, we can create, display, and compare large-size data on a single page. It is a user-friendly, easy, simple, and sorted method to display data using scatter plots in Pandas.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA