| Reference | Downloads | Github

How to make Rating Scale slider less precise?


I am new to PsychoPy and I am looking to make an experiment involving the default setting on sliders for things like loan calculators. I have been using the example code in the RatingScale demo but I have run into a small problem. My scale goes from 0 to 10000 and I need it to move in increments of 50. This will allow my participants to pick round numbers like they would in real life. I thought setting precision to equal 0.02 would do the trick but this doesn’t seem to work. And there are too many possible options to use the choice argument I think.

Any idea how to solve this problem? Moving in increments of 1 is too granular for my purposes. Thanks!


I think using the choices argument in conjunction with labels and tickmarks could be your best option here.

Would something like this accomplish what you want:

from psychopy import visual

# Rating scale details
minloan = 0
maxloan = 10000
loanrange = range(minloan, maxloan+1, 50)
labelpoints = [0, 0.25, 0.5, 0.75, 1.0]  # the fractions of the range you want to have labels at
labels = [str(int(maxloan * point)) for point in labelpoints]  # the actual text for each label
ticks = [len(loanrange) * point for point in labelpoints]  # the position along the track for each label

win = visual.Window()

ratingScale = visual.RatingScale(win, choices=loanrange,
                                 labels=labels, tickMarks=ticks)
item = visual.TextStim(win, "Test")
while ratingScale.noResponse:
rating = ratingScale.getRating()


It allows people to choose any multiple of 50, and only displays labels at the indicated points.

/Edit: Made a slight adjustment to the code for labels and tickmarks


I like Jan’s code better than mine, so I recommend that. But here’s another way to think about the issues. You can use the mechanics of a scale to have people interact with it, but display whatever value you want. So it looks like you are selecting a multiple of 50, but behind the scenes it is a different numeric scale. For that reason, you have to remember to convert the rating values back to 0 - 10000 (which is why I like Jan’s better).

from psychopy import visual

win = visual.Window(size=(1440, 900), fullscr=False)

rs = visual.RatingScale(win=win, name='rs', precision=10, low=0, high=20, 
    marker='slider', scale=None, 
    labels=['$0', '$10,000'], showValue=False)
val = visual.TextStim(win)

while rs.noResponse:
    val.text = '$' + str(int((rs.getRating() or 0) * 500))

rating = rs.getRating() * 500  # this is the ugly part
1 Like

Hi Jan,

Thank you so much, your code accomplishes exactly what I was looking for! :slight_smile:
I would have never thought of making the labels and ticks using for loops like that. In fact I didn’t even know it was possible. I evidently have a lot to learn.

I really appreciate your help!


Hi Jeremy,

Thank you so much for showing me how make the scale’s external appearance differ from its internal representation.
This will be extremely useful if we want to randomly alter the magnitude of the scale. I can simply change 500 to a variable that can take on different values. It would be interesting to see if the anchoring effect of the default position for the slider is larger when the scale goes from 0-100,000 than when it goes from 0-10,000.

I am very grateful for your help!



no problem! The one-line for loops for making a list are a great python feature called list comprehension. There’s a good blogpost here: