前言:
此时兄弟们对“c语言作图函数”大概比较关怀,朋友们都想要了解一些“c语言作图函数”的相关文章。那么小编在网上收集了一些对于“c语言作图函数””的相关资讯,希望大家能喜欢,小伙伴们一起来学习一下吧!1.线型图
import numpy as npimport pandas as pdfrom pandas import Series,DataFrameimport matplotlib.pyplot as pltnp.random.seed(0)s = Series(np.random.randn(10).cumsum(),index = np.arange(0,100,10))s.plot()plt.show(s.plot())
简单的DataFrame图标示例
np.random.seed(0)df = DataFrame(np.random.randn(10,4).cumsum(0), columns= ['A','B','C','D'], index = np.arange(0,100,10))plt.show(df.plot())
2.柱状图
水平和垂直柱状图
fig,axes = plt.subplots(2,1)data = Series(np.random.rand(16),index = list('abcdefghijklmnop'))data.plot(kind = 'bar',ax = axes[0],color = 'b',alpha = 0.9)data.plot(kind = 'barh',ax = axes[1],color = 'b',alpha = 0.9)
DataFrame柱状图示例
df = DataFrame(np.random.rand(6,4), index = ['one','two','three','four','five','six'], columns = pd.Index(['A','B','C','D'],name = 'Genus'))plt.show(df.plot(kind = 'bar'))
df = DataFrame(np.random.rand(6,4), index = ['one','two','three','four','five','six'], columns = pd.Index(['A','B','C','D'],name = 'Genus'))plt.show(df.plot(kind = 'bar',stacked = True))
3.直方图和密度图
直方图是一种可以对值频率进行离散化显示的柱状图,通过Series的hist方法
random随机数百分比的直方图
a = np.random.random(10)b = a/a.sum()s = Series(b)plt.show(s.hist(bins = 100)) #bins直方图的柱数
random随机数百分比的密度图
a = np.random.random(10)b = a/a.sum()s = Series(b)plt.show(s.plot(kind = 'kde'))
带有密度估计的规格化直方图
%matplotlib inlinecomp1 = np.random.normal(0,1,size = 200)comp2 = np.random.normal(10,2,size = 200)values = Series(np.concatenate([comp1,comp2]))p1 = values.hist(bins = 100,alpha = 0.3,color = 'k',normed = True)p2 = values.plot(kind = 'kde',style = '--',color = 'r')
4.散布图
一张简单散布图
df = DataFrame(np.random.randint(0,100,size = 100).reshape(50,2),columns = ['A','B'])df.plot('A','B',kind = 'scatter',title = 'x Vs y')
散布图矩阵
import numpy as npimport pandas as pdfrom pandas import Series,DataFrame%matplotlib inlinedf = DataFrame(np.random.randn(200).reshape(50,4),columns = ['A','B','C','D'])pd.plotting.scatter_matrix(df,diagonal = 'kde',color = 'k')
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。
标签: #c语言作图函数