Today I recommend a lightweight Python Statistical drawing library :Dexplot, So you don't have to use Python-matplotlib Library can draw exquisite statistical charts . Take a look at this lightweight statistical mapping Library ~, Welcome to collect and learn , Like to like and support , At the end of the article, a technical exchange group is provided .
Dexplot The official website of the library is as follows :https://www.dexplo.org/dexplot/ , More content not covered in this tweet , You can check this website by yourself ~
Dexplot The installation of the library is also very simple , as follows :
pip install dexplot
Dexplot The library also supports “ Long data ” and “ Wide data ” type , This and R-ggplot2 The data types required for drawing are similar (ggplot2 Only long data is supported ), The following two figures show what long data and wide data are :
Dexplot The library provides drawing functions for drawing different charts , But its basic usage syntax is as follows :
dxp.plotting_func(x, y, data, aggfunc, split, row, col, orientation, ...)
The parameters are explained as follows :
x: Along the x The column name of the axis
y: Along the y The column name of the axis
data:Pandas DataFrame data type .
aggfunc:pandas Common clustering calculation functions .
split: Data column names that divide data into different groups .
row: Data column name used to split data into different subgraphs by row .
col: Data column name used to split data into different subgraphs by column .
orientation: Drawing direction , Have vertical (‘v’) Or level (‘h’). The default setting for most graphs is vertical .
Dexplot The drawing library mainly provides two data types: cluster map and distribution map , The aggregation graph takes a series of values , And use the information provided to aggfunc The function of returns a single value , The distribution diagram takes a series of values and describes the distribution shape in some way .
Next , Learn quickly Python It will be shown through specific visual charts Dexplot Library drawing charm .
「 Example 1 」: Column chart series
import dexplot as dxp
import pandas as pd
import matplotlib.pyplot as plt
airbnb = dxp.load_dataset('airbnb')
#bar01
dxp.bar(x='neighborhood', y='price', data=airbnb, aggfunc='median',figsize=(5,3.5),
bar_kwargs={
"color":"#0073C2","ec":"black"})
Example01 of dxp.bar
Sort :
dxp.bar(x='neighborhood', y='price', data=airbnb, aggfunc='median',
figsize=(5,3.5),sort_values='asc',bar_kwargs={
"color":"#0073C2","ec":"black"}) ```

level :
```python
dxp.bar(x='price', y='neighborhood', data=airbnb, aggfunc='median', figsize=(3,4),
orientation='h', sort_values='desc',bar_kwargs={
"color":"#EFC000","ec":"black"})
Example03 of dxp.bar
grouping :
dxp.bar(x='neighborhood', y='price', data=airbnb, aggfunc='median', split='superhost',figsize=(4,2.5),
cmap=["#0073C2","#EFC000"],bar_kwargs={
"ec":"black"})
Example04 of dxp.bar
Split up :
dxp.bar(x='neighborhood', y='price', data=airbnb, aggfunc='median', split='superhost',
col='property_type', col_order=['House', 'Condominium', 'Apartment'],
row='bedrooms', row_order=[1, 2, 3], sharey=False,cmap=["#0073C2","#EFC000"],
bar_kwargs={
"ec":"black"})
Example05 of dxp.bar
「 Example 2 」: Box diagram series
dxp.box(x='price', y='neighborhood', data=airbnb,cmap=["#CD534C"],figsize=(3,3))
Example01 of dxp.box
grouping :
dxp.box(x='price', y='neighborhood', data=airbnb,figsize=(3,3.5),
cmap=["#0073C2","#EFC000","#868686","#CD534C"],
split='property_type', split_order='desc')
Example02 of dxp.box
「 Example 3 」: Density map (KDE)
dxp.kde(x='price', data=airbnb, split='bedrooms', split_order=[1, 2, 3],
cmap=["#0073C2","#EFC000","#868686"])
Example of dxp.kde
「 Example 4 」: Scatter plot
dxp.scatter(x='longitude', y='latitude', data=airbnb,
split='neighborhood', col='bedrooms', col_order=[2, 3])
Example of dxp.scatter
Okay , The above is to learn quickly Python List several representative charts , More chart types and drawing methods , Interested partners can explore by themselves ~
Today I introduced a lightweight Python Statistical drawing library , It can be seen that , Using this library to draw statistical charts requires only one line of code .
But it requires high visualization ( Color 、 Layout 、 Scale and other attributes are customized ) Little buddy , Still suggest learning R-ggplot2 and Python-matplotlib. Each have advantages and disadvantages , Partners choose drawing tools according to their preferences ~~
Welcome to reprint 、 Collection 、 Gain some praise and support !
At present, a technical exchange group has been opened , Group friends have exceeded 2000 people , The best way to add notes is : source + Interest direction , Easy to find like-minded friends