I want to change the color of the blue bar in the histogram.
I've already changed the color of the background:
.ui.histogram.setBackground(background= pg.mkColor(37,37,37))
But I don´t know how to change the color of the Blue Bar. (I imported pyqtgraph as pg)
Does anybody know how to do this?
Thank you in advance
It's hard for me to make a answer that I'm certain of, because I don't have all information. For instance what is ui
in your question? Next time please make an MVCE.
Anyway, assuming you have a ImageView
object called imgView
the following should work:
alpha = 50
region = imgView.histogram.item.region
region.setBrush(color=(255, 0, 0, alpha))
for line in region.lines:
line.setPen(color=(255, 0, 0, 255))
Make sure that alpha
is smaller than 128. The value of 2 * alpha
will be used when you hover above the region, and you will get a warning if it exceeds 256.
By the way, the imgView.histogram.item
is a HistogramLutItem
. I got my answer by looking at its source code.