Use object as marker for visual.RatingScale

Hi there,

I’m programming an experiment in psychopy/python and would like to use a custom defined object (rectangle) as the marker for my rating scale.

As the documentation for visual.ratingscale says ‘Can also be set to a custom marker stimulus: any object with a .draw() method’, I was hoping to be able to set up a rectangle using visual.Rect and then draw this as the marker for the rating scale. However this does not work and I don’t know what to make of the rather unspecific error messages.

When I use text (using visual.TextStim) as a marker, as given in the documentation’s example, this works without problems.

Here is my code:

  • this does’t work:
rect_rate = visual.Rect(win, size=[0.5,1.5], units='cm', lineColor=[3, 157, 252], fillColor=[3, 157, 252])

rating_scale = visual.RatingScale(win=win, name='rating_scale', 
    marker=rect_rate, size=1.5, stretch=1.2, pos=[0.0, 0.0], low=0, high=1,
    precision=100, showValue=False, scale=None, showAccept = False, labels=['100% angry',
        '100% sad'])
  • this does work:
text = visual.TextStim(win, text='blablabla', units='norm')

rating_scale = visual.RatingScale(win=win, name='rating_scale', 
    marker=text, size=1.5, stretch=1.2, pos=[0.0, 0.0], low=0, high=1,
    precision=100, showValue=False, scale=None, showAccept = False, labels=['100% angry',
        '100% sad'])

I’m new to python/psychopy so would be very happy about any ideas about what is amiss here. Thanks!

As a workaround I tried to draw the rectangle on top of the rating scale, using the mouse position as rectangle position, while constraining it to the rating scale position on the y axis.

    while rating_scale.noResponse:
        rect_x = event.Mouse().getPos()[0]
        
        rect_rate.pos = [rect_x, 0]
        
        rating_scale.draw()
        ratings_text.draw()
        rect_rate.draw()
        win.flip()

This works so far, except for the fact that the rectangle moves only about 10% of the whole extent of the rating scale axis - see attached screenshots where one can see how the mouse position (red arrows) and rectangle position don’t align.


Perhaps someone can help me figure out where I’m going wrong here?