How can Seaborn library be used to visualize point plots in Python?

PythonServer Side ProgrammingProgramming

Seaborn is a library that helps in visualizing data. This interface helps in customizing and controlling the kind of data and how it behaves when certain filters are applied to it.

With the help of bar plots, we can understand the central tendency of the distribution of data. The barplot function establishes the relationship between a categorical variable and a continuous variable.

Data is represented in the form of rectangular bars where the length of the bar indicates the proportion of data in that specific category.

Point plots are similar to bar plots but instead of representing the fill bar, the estimated value of the data point is represented by a point at a specific height on the other axis. Here’s the example −

Example

import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
my_df = sb.load_dataset('titanic')
sb.pointplot(x = "sex", y = "survived", hue = "class", data = my_df)
plt.show()

Output

Explanation

  • The required packages are imported.
  • The input data is ‘titanic’ which is loaded from the seaborn library.
  • This data is stored in a dataframe.
  • The ‘load_dataset’ function is used to load the iris data.
  • This data is visualized using the ‘pointplot’ function.
  • Here, the dataframe is supplied as parameter.
  • Also, the x and y values are specified.
  • This data is displayed on the console.
raja
Published on 11-Dec-2020 10:42:46
Advertisements