numbas / numbas-extension-programming

An extension for Numbas which provides a code editor and the ability to evaluate code written in Python and R.
Apache License 2.0
3 stars 1 forks source link

Figure output repeats in subsequent parts and questions #10

Closed chrismgraham closed 2 years ago

chrismgraham commented 2 years ago

The changes we made to capture figures in 485feedc1433a5731175b268c2a3387868f826e7 have caused plots to appear in the stdout of subsequent code parts (including in further questions if in an exam). Minimal example here

Do we need a matplotlib preamble to clear any previous figures? I'm not sure if this would work or not...

if 'matplotlib' in sys.modules:
   import matplotlib.pyplot as plt
   if plt.gcf():
       plt.clf()