How to generate plot of reward and its variance?

I am new to reinforcement learning and I would like know how to generate a learning curve plot such as that shown below (taken from this blog post), that illustrates the reward (return) and its variance (shaded region). I would like to use Matplotlib or any other Python plotting framework.

Once you have the standard deviation (or variance) of the return, you can plot something like your plots using matplotlib's fill_between function.
• @CristianM It depends on what you want to estimate or visualise. If you want to estimate the variance of all episodes, then, suppose you have $N$ episodes, then you will have $N$ returns from which you can compute an average return and a variance. – nbro Apr 18 at 13:12