[英]pyqtgraph histogram LUT Item - how to change color?
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) (我将pyqtgraph导入为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? 例如,您的问题中的ui
是什么? Next time please make an MVCE . 下次请制作MVCE 。
Anyway, assuming you have a ImageView
object called imgView
the following should work: 无论如何,假设您有一个名为imgView
的ImageView
对象,则应该可以进行以下操作:
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. 确保alpha
小于128。当您将鼠标悬停在区域上方时,将使用2 * alpha
值,如果该值超过256,则会收到警告。
By the way, the imgView.histogram.item
is a HistogramLutItem
. 顺便说一句, imgView.histogram.item
是HistogramLutItem
。 I got my answer by looking at its source code . 通过查看其源代码,我得到了答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.