Python3-数据可视化练习题(含答案):plt.legend(),plot.hist(。。。要想查阅有关style sheets, 请点击查阅
先展⽰所要使⽤的datat:画春
麻将术语import pandas as pd
import matplotlib.pyplot as plt
df3 = pd.read_csv('df3')
df3.info()
df3.head()
结果如下:
使⽤scatter():pdf怎么转换成cad图纸
# s: size
df3.plot.scatter(x='a',y='b',figsize=(12,5),s=50)
df3.plot.scatter(x='a',y='b',figsize=(12,5))
使⽤hist():
软件工程就业前景
# Create a histogram of the 'a' column
描写美食的词语df3['a'].hist()
df3['a'].plot.hist(bins=10,color='red',alpha=0.4)
使⽤style sheets:
# U style sheets to t the style to 'ggplot' and redo the histogram from above graph. Also figure out how to add more bins to it # ggplot: emulates the aesthetics of ggplot (a popular plotting package for R).
plt.style.u('ggplot')
df3['a'].plot.hist(bins=20,alpha=0.4)
结果如下:
使⽤plot.box():
# Create a boxplot comparing the a and b columns
df3[['a','b']].plot.box()
使⽤plot.kde():
怎么提高英语# Create a kde plot of the 'd' column
df3['d'].plot.kde()
结果如下:
身上长癣是什么原因引起的
kde() 和 density() ⼀样:
# Figure out how to increa the linewidth and make the linestyle dashed. df3['d'].plot.kde(lw=5,ls='--')
# Figure out how to increa the linewidth and make the linestyle dashed. df3['d'].plot.density(lw=5,ls='--')
使⽤plt.legend() 将标注框进⾏变换位置:
# 如何把lengend 移出图形外部?
df3['d'].plot.density(lw=5,ls='--')
# center right: 是以标注的中间右边框为标准点
plt.legend(loc='center right', bbox_to_anchor=(1,0.5)) # 如何把lengend 移出图形外部?
df3['d'].plot.density(lw=5,ls='--')
# center left: 是以标注的中间左边框为标准点
plt.legend(loc='center left', bbox_to_anchor=(1,0.5)) df3['d'].plot.density(lw=5,ls='--')
plt.legend(loc=(1.1,0))
如果觉得不错,就点赞或者关注或者留⾔~~谢谢~ ~樱花恋