Created
July 21, 2015 14:55
-
-
Save taddeimania/5cdd4ac24aff26feffa9 to your computer and use it in GitHub Desktop.
Graph to HttpResponse - django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponse | |
import matplotlib.pyplot as plt | |
import io | |
def graph_view(request): | |
plt.scatter([1, 2, 3, 4], [6, 10, 12, 1]) | |
image_file = io.BytesIO() | |
plt.savefig(image_file, format="png") | |
image_file.seek(0) | |
return HttpResponse(image_file, content_type="image/png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment