使用numpy.histogram的输出如何绘制简单曲线图?

时间:2019-03-02 08:50:54

标签: python numpy matplotlib

我想在x轴上绘制b / w public abstract class AlertDialogActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_alert_dialog); showAlertDialog(AlertDialogActivity.this); } public abstract void showAlertDialog(final Context context) { // 1. Instantiate an <code><a href="/reference/android/app/AlertDialog.Builder.html">AlertDialog.Builder</a></code> with its constructor AlertDialog.Builder builder = new AlertDialog.Builder(AlertDialogActivity.this); // 2. Chain together various setter methods to set the dialog characteristics builder.setMessage("How are you?") .setTitle("Hello"); // 3. Get the <code><a href="/reference/android/app/AlertDialog.html">AlertDialog</a></code> from <code><a href="/reference/android/app/AlertDialog.Builder.html#create()">create()</a></code> AlertDialog dialog = builder.create(); dialog.show(); } 图,在y轴上绘制概率图。

首先,我使用numpy.histogram命令计算概率。 a给了我机会。

但是n中的术语数取决于我选择的仓位数量。

如果我选择5个纸槽,那么在打印n时将有5个字词。

使用这些概率值,我可以选择y轴值。

但是我的目标是在n与概率之间绘制图,而在数组a中有9个项,在a中有5个项。

那么我如何将直方图的概率转换为简单的曲线图?

n

1 个答案:

答案 0 :(得分:0)

如果我理解正确,那应该可以

plt.plot(bins, np.append(n[0], n))