如何创建频率散点图(像直方图,但用点而不是条)和可选的误差条?
How to create frequency scatter plot(like histogram but with dots instead of bars) and with optional error bars?
有人知道如何在 python(matplotlib, pandas_bokeh,...) 中绘制带有误差线的频率散点图吗?
我想要的是在 y 轴上有事件数(计数,而不是值)和 x 轴上的相应值,实际上就像直方图,但我想使用点而不是条形图。并可能在提到的点上添加错误栏。
它看起来像这样:
使用 numpy.hist
和 plt.errorbars
的组合:
import numpy as np
import matplotlib.pyplot as plt
x = np.random.normal(size=(20000, ))
hist, bin_edges = np.histogram(x, bins=50, density=False)
bin_center = (bin_edges[:-1] + bin_edges[1:])/2
plt.figure()
plt.hist(x, bins=50, density=False)
plt.errorbar(bin_center, hist, yerr=50, fmt='.')
plt.show()
有人知道如何在 python(matplotlib, pandas_bokeh,...) 中绘制带有误差线的频率散点图吗?
我想要的是在 y 轴上有事件数(计数,而不是值)和 x 轴上的相应值,实际上就像直方图,但我想使用点而不是条形图。并可能在提到的点上添加错误栏。
它看起来像这样:
使用 numpy.hist
和 plt.errorbars
的组合:
import numpy as np
import matplotlib.pyplot as plt
x = np.random.normal(size=(20000, ))
hist, bin_edges = np.histogram(x, bins=50, density=False)
bin_center = (bin_edges[:-1] + bin_edges[1:])/2
plt.figure()
plt.hist(x, bins=50, density=False)
plt.errorbar(bin_center, hist, yerr=50, fmt='.')
plt.show()