本来想用python画个圣诞树的,结果想到了seaborn.swarmplot,仔细一看还真像,促合着当圣诞树吧~~~~~~
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(dpi=170)
tips = sns.load_dataset("tips")
ax = sns.swarmplot(
x=tips["total_bill"],
color='green',#也可以指定调色盘
orient='v',
**dict(marker='*', s=7),#marker属性设置
)
plt.axis('off')
plt.show()
换个幸运草的圣诞树~~~
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(dpi=170)
tips = sns.load_dataset("tips")
ax = sns.swarmplot(
x=tips["total_bill"],
color='green',
orient='v',
**dict(marker='$\clubsuit$', s=7),
)
plt.axis('off')
plt.show()
画个挂满小心心的圣诞树~~~
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(dpi=170)
tips = sns.load_dataset("tips")
ax = sns.swarmplot(
x=tips["total_bill"],
color='red',
orient='v',
**dict(marker='$\heartsuit$', s=9,),
)
plt.axis('off')
plt.show()
更多形状戳:Python可视化|matplotlib03-一文掌握marker和linestyle使用
分组画~~~
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(dpi=170)
tips = sns.load_dataset("tips")
ax = sns.swarmplot(
x="time",
y="total_bill",
data=tips,
size=6,
color='green',
orient='v',
palette='Set1',#调色盘
**dict(marker='*', s=7),
)
plt.axis('off')
plt.show()
更细的分组~~~~
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(dpi=170)
tips = sns.load_dataset("tips")
ax = sns.swarmplot(
x="day",
y="total_bill",
#hue="sex",
data=tips,
color='green',
orient='v',
palette='Set1',
**dict(marker='*', s=7),
)
plt.axis('off')
plt.show()