Select version 0.11 here
Seaborn, one of the data libraries on Python, has a new version, Seaborn version 0.11, with many new updates. One of the biggest changes is that Seaborn now has a nice logo. Apart from all the jokes, the new version contains many new features to improve the visualization of the data. This is a short blog post with several updates for Seaborn.
displot() for one- and two-dimensional divisions
One of the most important changes is the update of the distribution functions in the Seaborn 0.11 version. The new version of Seaborn includes three new functions displot(), histplot() and ecdfplot() which make it easier to view the distributions. Yes, we no longer need to write our own function to write the history of the CSDF.
Seaborn can be used to visualize one- and two-dimensional distributions. Among these three new functions, the display function provides a numerical-level interface for general distribution graphs in the seaport, including bar graphs (histograms), density graphs, empirical distributions (ecdfplots) and carpet graphs. For example, we can use displot() and a
- histplot() with type=hist (default)
- kdeplot() (with child=kde)
- ecdfplot() (with species=ecdf)
We can also add the backplot() function to display the actual values of the data on each of these graphs.
Not to be confused with distplot() for displot(). displot() is a new distplot() with better properties and distplot() has been written off since this version of Seaborn.
With the new displot() function in Seaborn, the hierarchy of functions for drawing diagrams looks like this, which now includes most of the possibilities for drawing diagrams
Hierarchy of Serboarding functions
Besides catplot() for categorical variables and relplot() for relational graphs, we now have displot() for distribution graphs.
Let’s try a few features. We can download the latest version of Seaborn
Pipeline installation Offshore workstation
Let’s download Seaborn and make sure we have Seaborn version 0.11.
Import at sea as sns
We will use the Palm Penguin dataset to illustrate some of the new features and capabilities of the seaport. Penguin data is directly available for shipping, and we can load it with the load_dataset() function.
penguins = sns.load_dataset(penguins)
beak_length_mm beak_depth_mm flipper_length_mm body_massa_g Gender
0 Adelie Torgersen 39,1 18,7 181,0 3750,0 Male
1 Adelie Torgersen 39.5 17,4 186,0 3800,0 Female
2 Adeli Torgersen 40,3 18,0 195,0 3250,0 Female
3 Adeli Torgersen NaN
4 Adeli Torgersen 36,7 19,3 193,0 3450,0 Female
We can create histograms with Seaborn’s histplot(), KDE plot with kdeplot() and ECDF plot with ecdfplot(). But first we use the displot() function to illustrate the new functions of Seaborn.
Histograms with Seaborn() display
Let’s create a simple histogram with the Seaborn() function.
Here we set the number of bins on the histogram.
Histogram reconstructed with the displot() function
We can also create the histogram in variable colors and overlapping histograms.
In this example we colour the mass of penguins per species.
Displot of sailors() : Laying histograms on top of each other with a colour tone
Facet with sea grain()Display
You can use the col argument to create small multiples or facets to create multiple graphs of the same type with subsets of data based on the value of the variable.
In our dataset we discovered values for penguin species.
Displot of sailors() : Create a facetted histogram using columns
Density diagram with Seaborn() display
Let’s use the displot() function and create a density diagram with the view=k argument. Here, too, we paint by species in a variable manner with a colour argument.
Displot of sailors() : Core density diagrams
Read the Seaborn documentation, the new version offers new possibilities for creating density diagrams.
ECDF plot with sea bass() display
One of the highlights of the Seaborn update is the availability of a function to create an ECDF card. The ECDF, also known as the Empirical Cumulative Distribution, is an excellent alternative to visualizing distributions.
In the ECDF table, the x-axis corresponds to the range of data values for the variables, and on the y-axis we record the proportions of the data points (or counts) that are smaller than the corresponding value on the x-axis.
Unlike bar graphs and density diagrams, ECDF diagrams allow direct visualization of the data without flattening parameters such as the number of bits. The use is possible if multiple visualization distributions are available.
One possible drawback is that…
The relationship between the appearance of the plot and the basic characteristics of the distribution (such as central tendency, distribution, presence of bimodality) may be less intuitive.
Let’s create ecdf graphics with the displot() function with child=ecdf. Here we make an ecdf-diagram of one variable and color it according to the values of another variable.
Displot of sailors() : Slot for Empirical Cumulative Density Function (ECDF)
Bivariate KDE diagram and histogram with displot() function
With kdeplot() we can also map the density of binary options. In this example we use the function displot() with the function child=’kde’ to draw the binary contour/density diagram.
Sea drill displot(): Two-dimensional KDE density diagram
We can also create a bivariate histogram with the displot() function, using the type=hist or histplot() option to create a density graph.
Biographical Diagram of Seaborn()
New features of the common parcel of Seaborn()
With Seaborn 0.11 the Jointplot also got some good properties. Now the jointplot() function can accept as an argument a hue to color the data points of a variable.
Workshop colour with a variable tint.
And the jointplot() function also offers the possibility to create an invariant histogram on the common axes and a one-dimensional histogram on the extreme axes with the argument view=hist in the jointplot() function.
Color of the sea trench per variable : Bi-variant histogram
Another big change that will help in writing better code for data visualization is that most of Seaborn’s graphical features now require you to define your parameters with keyword arguments. Otherwise you will see FutureWarning under version 0.11.
As part of this update, Seaborn has also received documentation about its capabilities. Read the new data structure documentation included in Seaborn’s tracking features. Some functions can accept data in a broad and long sense. Currently the distribution and relational drawing functions can handle both functions of Seaborn, in future versions the same input data will be available.