28👍
✅
You need to remove the num
parameter from the figure constructor and close the figure when you’re done with it.
import matplotlib.pyplot
def test_matplotlib(request):
f = figure(figsize=(6,6))
....
matplotlib.pyplot.close(f)
By removing the num
parameter, you’ll avoid using the same figure at the same time. This could happen if 2 browsers request the image at the same time. If this is not an issue, another possible solution is to use the clear method, i.e. f.clear()
.
0👍
1.save picture which created by matplotlib
for example:plt.savefig(‘./app1/static/visualize.png’)
2.use the picture in your html code
for example:
about django how to use static variable(like picture and js file) you can refer to django document
- [Django]-Django objects.filter() values_list() vs python list comprehension for __in query
- [Django]-How do I use CSS in Django?
- [Django]-Django: How to check if the user left all fields blank (or to initial values)?
Source:stackexchange.com