草庐IT

histogram

全部标签

Python直方图大纲

我在Jupyter(Python2)中绘制了一个直方图,并希望看到我的条形图的轮廓,但事实并非如此。我正在使用以下代码:importmatplotlib.pyplotaspltfromnumpy.randomimportnormalgaussian_numbers=normal(size=1000)plt.hist(gaussian_numbers)plt.title("GaussianHistogram")plt.xlabel("Value")plt.ylabel("Frequency")plt.show() 最佳答案 您的lin

Python直方图大纲

我在Jupyter(Python2)中绘制了一个直方图,并希望看到我的条形图的轮廓,但事实并非如此。我正在使用以下代码:importmatplotlib.pyplotaspltfromnumpy.randomimportnormalgaussian_numbers=normal(size=1000)plt.hist(gaussian_numbers)plt.title("GaussianHistogram")plt.xlabel("Value")plt.ylabel("Frequency")plt.show() 最佳答案 您的lin

python - 用python拟合直方图

我有一个直方图H=hist(my_data,bins=my_bin,histtype='step',color='r')我可以看到形状几乎是高斯的,但我想用高斯函数拟合这个直方图并打印我得到的平均值和sigma的值。你能帮帮我吗? 最佳答案 这里有一个使用py2.6和py3.2的示例:fromscipy.statsimportnormimportmatplotlib.mlabasmlabimportmatplotlib.pyplotasplt#readdatafromatextfile.Onenumberperlinearch="t

python - 用python拟合直方图

我有一个直方图H=hist(my_data,bins=my_bin,histtype='step',color='r')我可以看到形状几乎是高斯的,但我想用高斯函数拟合这个直方图并打印我得到的平均值和sigma的值。你能帮帮我吗? 最佳答案 这里有一个使用py2.6和py3.2的示例:fromscipy.statsimportnormimportmatplotlib.mlabasmlabimportmatplotlib.pyplotasplt#readdatafromatextfile.Onenumberperlinearch="t

python直方图单线

这个问题在这里已经有了答案:Usingadictionarytocounttheitemsinalist(7个回答)关闭3个月前。有很多方法可以编写计算直方图的Python程序。直方图是指一个函数,它计算iterable中对象的出现次数并在字典中输出计数。例如:>>>L='abracadabra'>>>histogram(L){'a':5,'b':2,'c':1,'d':1,'r':2}编写此函数的一种方法是:defhistogram(L):d={}forxinL:ifxind:d[x]+=1else:d[x]=1returnd这个函数有更简洁的写法吗?如果我们在Python中有字典推

python直方图单线

这个问题在这里已经有了答案:Usingadictionarytocounttheitemsinalist(7个回答)关闭3个月前。有很多方法可以编写计算直方图的Python程序。直方图是指一个函数,它计算iterable中对象的出现次数并在字典中输出计数。例如:>>>L='abracadabra'>>>histogram(L){'a':5,'b':2,'c':1,'d':1,'r':2}编写此函数的一种方法是:defhistogram(L):d={}forxinL:ifxind:d[x]+=1else:d[x]=1returnd这个函数有更简洁的写法吗?如果我们在Python中有字典推

python - 将 pandas.Series 直方图保存到文件

在ipythonNotebook中,首先创建一个pandasSeries对象,然后调用实例方法.hist(),浏览器显示图形。我想知道如何将此图保存到文件中(我的意思不是右键单击并另存为,而是脚本中需要的命令)。 最佳答案 使用Figure.savefig()方法,像这样:ax=s.hist()#sisaninstanceofSeriesfig=ax.get_figure()fig.savefig('/path/to/figure.pdf')不必以pdf结尾,有很多选择。查看thedocumentation.或者,您可以使用pypl

python - 将 pandas.Series 直方图保存到文件

在ipythonNotebook中,首先创建一个pandasSeries对象,然后调用实例方法.hist(),浏览器显示图形。我想知道如何将此图保存到文件中(我的意思不是右键单击并另存为,而是脚本中需要的命令)。 最佳答案 使用Figure.savefig()方法,像这样:ax=s.hist()#sisaninstanceofSeriesfig=ax.get_figure()fig.savefig('/path/to/figure.pdf')不必以pdf结尾,有很多选择。查看thedocumentation.或者,您可以使用pypl

python - Matplotlib - 标记每个 bin

我目前正在使用Matplotlib创建直方图:importmatplotlibmatplotlib.use('Agg')importmatplotlib.pyplotaspyplot...fig=pyplot.figure()ax=fig.add_subplot(1,1,1,)n,bins,patches=ax.hist(measurements,bins=50,range=(graph_minimum,graph_maximum),histtype='bar')#ax.set_xticklabels([n],rotation='vertical')forpatchinpatches:

python - Matplotlib - 标记每个 bin

我目前正在使用Matplotlib创建直方图:importmatplotlibmatplotlib.use('Agg')importmatplotlib.pyplotaspyplot...fig=pyplot.figure()ax=fig.add_subplot(1,1,1,)n,bins,patches=ax.hist(measurements,bins=50,range=(graph_minimum,graph_maximum),histtype='bar')#ax.set_xticklabels([n],rotation='vertical')forpatchinpatches: