Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] Plots generated by matplotlib to show on canvas in OpenSesame.

edited September 2015 in OpenSesame

Hi,

I am making a psychology experiment.
I want to present random number of dots on Canvas.
Number of dots have to be changed every trial.( Maybe 1000)
I made a code to plot random number of dots with matplotlib.
But I cannot show plots on canvas.
Is there anyway for me to show plots on Canvas?
I tried to make it as an image first and bring it out to canvas, but it did not work well.
Do you guys have any Idea with this problem?

Comments

  • edited 10:20AM

    I tried to make it as an image first and bring it out to canvas, but it did not work well.

    matplotlib cannot draw directly on an OpenSesame canvas, so this would indeed be the way to go. I did this once, and it worked. One quirk was that matplotlib seemed to steel the window focus, so you had to click in the OpenSesame window to continue the experiment. Other than that it worked fine. What kind of problems are you running into?

  • edited 10:20AM

    Hi,

    The most 'OpenSesame way' to show a plot would indeed be through canvas.image() I think; although there is a much easier and more direct way to present random dots on a canvas. In an inline_script, you could do the following:

       import random
       canvas = canvas(exp)
    
       for i in range(0, randint(1,1000)):  #runs loop between 1 and 1000 times
               canvas.fixdot(x=randint(-512,512), y=randint(-384, 384))
    
       canvas.show()
    

    Does that help?

    Cheers,

    Josh

  • edited 10:20AM

    Great!
    Thanks Josh

    Seo

Sign In or Register to comment.