Django
私が使用matplotlib
している で Web ベースのヘビとはしごゲームmpld3
を作成し、Web ページにゲームデータを作成して表示しようとしています。
Web ページで画像を取得できますが、反転しています。
このコードのどこが間違っていますか?
私のviews.pyファイル:
import matplotlib.image as mpimg
import mpld3 as mpld3
import numpy as np
import matplotlib.pyplot as plt
def home(request):
image = mpimg.imread('platform3.png')
figure = plt.figure(dpi=100)
subplot = figure.add_subplot(111)
subplot.set_xlim(0, 10)
subplot.set_ylim(0, 10)
subplot.imshow(image, extent=[0, 10, 0, 10])
canvas = FigureCanvas(figure)
response = django.http.HttpResponse(content_type='image/png')
canvas.print_png(response)
html_gen = 'graph.html'
with open(html_gen, 'w') as f:
f.write(mpld3.fig_to_html(figure))
f.write("Hello")
return render(request, html_gen)
生成された html_gen.html ファイルも提供する必要がありますか?