Real Time Plotting

Hey, I’m looking to do real time plotting as data as being gathered. I am looking to use PsychoPy to manage experiments, but it seems that for graphing they typically use matplotlib. I know how to update a line graph as data comes in within matplotlib, but I don’t think I’m able to do so when I embed that inside of PsychoPy. It seems that most people are saving the plot as an image, making it into an ImageStim, and repeating the process. That seems like it is probably really slow.

I saw this, but it doesn’t seem like a clean solution… using ShapeStim for connecting each point on the line to the next and possible resizing seems like it would be really messy.

I’m wondering:

  • How much time do you think that it will cost to save the matplotlib images and then add them as ImageStim? Is it efficient enough that it would be worth just doing that?
  • Is there a better way to do this?

I think everything depends on the rate at which data is coming in and if you want your plot to reflect that rate. I suspect that even with a few updates per second the matplotlib approach could work so I would definitely try it to see if it meets your needs and just be pragmatic about it :slight_smile:

The only other alternative I can think of is implementing your own plotting functions within PsychoPy, but this is not so trivial. So although this will probably allow you to render a real time graph much faster, it will take a lot of work to implement it (and you also need to implement it in an efficient way in order for it to be faster).

1 Like