其他
10个超级实用的数据可视化图表总结!
↓推荐关注↓
来源:爱数据LoveData
1、平行坐标图
Parallel Coordinate
import plotly.express as px
df = px.data.iris()
fig = px.parallel_coordinates(df, color="species_id", labels={"species_id": "Species",
"sepal_width": "Sepal Width", "sepal_length": "Sepal Length",
"petal_width": "Petal Width", "petal_length": "Petal Length", },
color_continuous_scale=px.colors.diverging.Tealrose,
color_continuous_midpoint=2)
fig.show()
六边形分箱图
Hexagonal Binning
等高线密度图
Contour
import plotly.express as px
fig = px.density_contour(df, x="sepal_width", y="sepal_length")
fig.update_traces(contours_coloring="fill", contours_showlabels = True)
fig.show()
4、QQ-plot
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
np.random.seed(10)
# Generate Univariate Observations
gauss_data = 5 * np.random.randn(100) + 50
sns.histplot(data=gauss_data, kde=True)
import statsmodels.api as sm
# q-q plot
sm.qqplot(gauss_data, line='s')
plt.show()
小提琴图
Violin Plot
import seaborn as sns
sns.violinplot(data=df, y="sepal_width")
import seaborn as sns
sns.violinplot(data=df,x='species', y="sepal_width")
箱线图的改进版
Boxen plot
sns.boxenplot(x=df["sepal_width"])
sns.boxenplot(data=df, x="species",y='sepal_width')
点图
下图中有一些名为误差线的垂直线和其他一些连接这些垂直线的线。让我们看看它的确切含义。
import seaborn as sns
sns.pointplot(data=df,x="species", y="sepal_width")
分簇散点图
Swarm plot
import seaborn as sns
sns.swarmplot(data=df,x="species", y="sepal_width")
旭日图
Sunburst Chart
import plotly.express as px
df = px.data.tips()
fig = px.sunburst(df, path=['sex', 'day', 'time'],
values='total_bill', color='time')
fig.show()
词云
Word Cloud
数据集:
https://opendatacommons.org/licenses/odbl/1-0/
import pandas as pd
data=pd.read_csv('/work/android-games.csv')
data.head()
data.category.value_counts()
GAME CARD 126
GAME WORD 104
GAME ACTION 100
GAME ADVENTURE 100
GAME STRATEGY 100
GAME PUZZLE 100
GAME SIMULATION 100
GAME CASUAL 100
GAME ARCADE 100
GAME ROLE PLAYING 100
GAME TRIVIA 100
GAME BOARD 100
GAME CASINO 100
GAME RACING 100
GAME EDUCATIONAL 100
GAME SPORTS 100
GAME MUSIC 100
Name: category, dtype: int64
#importing the module from wordcloud library
from wordcloud import WordCloud
import matplotlib.pyplot as plt
#creating a text from the category column by taking only the 2nd part of the category.
text = " ".join(cat.split()[1] for cat in data.category)
#generating the cloud
word_cloud = WordCloud(collocations = False, background_color = 'black').generate(text)
plt.imshow(word_cloud, interpolation='bilinear')
plt.axis("off")
plt.show()
结数据可视化是数据科学中不可缺少的一部分。在数据科学中,我们与数据打交道。手工分析少量数据是可以的,但当我们处理数千个数据时它就变得非常麻烦。如果我们不能发现数据集的趋势和洞察力,我们可能无法使用这些数据。希望上面介绍的的图可以帮助你深入了解数据。
https://plotly.com/python/parallel-coordinates-plot/
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.plot.hexbin.html
Hintze, V. P. A Box Plot-Density Trace Synergism. Am. Sat, (52), 181 (Open Access Journal).
seaborn.pointplot — seaborn 0.12.1 documentation (pydata.org)
seaborn.swarmplot — seaborn 0.12.1 documentation (pydata.org)
Create a sunburst chart in Office — Microsoft Support
万水千山总是情,点个 👍 行不行。
- EOF -
加主页君微信,不仅Python技能+1
主页君日常还会在个人微信分享Python相关工具、资源和精选技术文章,不定期分享一些有意思的活动、岗位内推以及如何用技术做业余项目
加个微信,打开一扇窗
觉得本文对你有帮助?请分享给更多人
推荐关注「Python开发者」,提升Python技能
点赞和在看就是最大的支持❤️