你需要num从图形构造函数中删除该参数,并在完成后关闭图形。
import matplotlib.pyplotdef test_matplotlib(request): f = figure(figsize=(6,6)) .... matplotlib.pyplot.close(f)
通过删除该num参数,你将避免同时使用同一图形。如果2个浏览器同时请求图像,则可能会发生这种情况。如果这不是问题,则另一种可能的解决方案是使用clear方法,即f.clear()。

你需要num从图形构造函数中删除该参数,并在完成后关闭图形。
import matplotlib.pyplotdef test_matplotlib(request): f = figure(figsize=(6,6)) .... matplotlib.pyplot.close(f)
通过删除该num参数,你将避免同时使用同一图形。如果2个浏览器同时请求图像,则可能会发生这种情况。如果这不是问题,则另一种可能的解决方案是使用clear方法,即f.clear()。