need help setting the tick positions in a histogramLUT

23 views
Skip to first unread message

Jeremy Webster

unread,
Apr 2, 2020, 6:50:07 PM4/2/20
to pyqtgraph

Hi

I am trying to programmatically move one of the ticks in the gradient editor of a histogramLUT.  I tried this...


hist = pg.HistogramLUTItem()
hist.setImageItem(my_image)
hist.gradient.loadPreset('yellowy')
current_ticks = hist.gradient.listTicks()
hist
.gradient.setTickValue(current_ticks[2], 0.4)

But I get the error:

File "/Users/myname/directory/plot.py", line 99, in update_images
    hist.gradient.setTickValue(current_ticks[2], 0.4)
  File "/Users/myname/opt/anaconda3/envs/my_env/lib/python3.6/site-packages/pyqtgraph/graphicsItems/GradientEditorItem.py", line 309, in setTickValue
    pos = tick.pos()
AttributeError: 'tuple' object has no attribute 'pos'

Am I missing something?  Or is there a better way to do this?

Thanks
J

Jeremy Webster

unread,
Apr 2, 2020, 8:23:39 PM4/2/20
to pyqtgraph

I figured it out I think.  hist.gradient.listTicks() returns a list of tuples with the tick object in the 0 position and (I believe) the position in the second.  So changing the setTickValue line to...

hist.gradient.setTickValue(current_ticks[2][0], 0.7)

runs, and changes the position of the tick on the widget

Thanks for your time, carry on
Reply all
Reply to author
Forward
0 new messages