4

pyqtgraph の例には、以下に示すように、x 軸に沿って変数を、y 軸に沿ってカウントを使用してヒストグラムを作成する方法が含まれています。変数を y 軸に沿って実行し、カウントを x 軸に沿って実行し、fillLevel を y 軸に塗りつぶす方法はありますか?

import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np

win = pg.GraphicsWindow()
win.resize(800,350)
win.setWindowTitle('pyqtgraph example: Histogram')
plt1 = win.addPlot()

## make interesting distribution of values
vals = np.hstack([np.random.normal(size=500), np.random.normal(size=260, loc=4)])

## compute standard histogram
y,x = np.histogram(vals, bins=np.linspace(-3, 8, 40))

## notice that len(x) == len(y)+1
## We are required to use stepMode=True so that PlotCurveItem will interpret this data correctly.
curve = pg.PlotCurveItem(x, y, stepMode=True, fillLevel=0, brush=(0, 0, 255, 80))
plt1.addItem(curve)
4

1 に答える 1

4

PlotCurveItem は常に、独自の座標系内で水平な線まで塗りつぶされます。したがって、y 軸まで塗りつぶしたい場合は、回転する必要があります。

curve.rotate(90)
于 2013-09-19T14:57:51.123 に答える