Installation: The easiest way to install Seaborn — this is to use pip. Enter the following command in terminal:
pip install seaborn
OR you can download it from here and set manually.
Plot plotting with Seaborn
Explanation: This one kind of categorized data using seaborn.
- Categorical data is represented on the X-axis, and the values correspond to them, represented on the Y-axis.
- Function. striplot () is used to define the type of plot and applied to the canvas using.
- The .set () function is used to set labels X and Y axes.
- The .title () function is used to assign a title to the graph.
- To view the graph, we use the .show function () .
Stripplot using built-in kit yes data specified in seaborn:
- iris — this is a dataset already present in the seaborn module for use.
- We use the .load_dataset () function to load the data. We can also upload any other file by specifying the path and filename in the argument.
- The .set (style = ”whitegrid”) function is also used here to define the background of the plot. We can use "darkgrid"
instead of whitegrid if we want a dark background.
- In the .stripplot () function, we define which the dataset attribute should be on the x-axis and which dataset attribute should be on the y-axis. data = iris means the attributes we defined earlier should be taken from the data.
- We can also draw this plot using matplotlib, but the problem with matplotlib — these are the default options. The reason Seaborn is so good at DataFrames is, for example, because labels from DataFrames are automatically propagated to charts or other data structures, as you can see in the above figure. The View column name occurs along the x-axis, and the column name stepal_length occurs in y-aixs. , this is not possible with matplotlib. We must explicitly define the x-axis and y-axis labels.
This is very similar to a stripplot, but the only difference is that markers must not be overlapped. This causes the plot markers to jitter, so the plot can be easily read without loss of information as seen in the plot above.
- We use the .swarmplot () function to plot the Swarn plot.
- Another difference that we can notice in Seaborn and Matplotlib is that working with DataFrames is not so smooth with Matplotlib, which can be annoying if we are doing exploratory analysis with Pandas. And that’s exactly what Seaborn makes easy, the plotting functions work with DataFrames and arrays that contain a whole set of data.
NOTE. If we wish, we can also change the presentation of data on a specific axis. For example:
The same can be done in stripplot. Finally, we can say that Seaborn — it is an extended version of matplotlib that tries to simplify a clear set of tricky things.