fixed a bug with matplotlib.pyplot.subplots() causing resizing of windows

This commit is contained in:
Dewey Cox
2022-05-19 09:11:28 -06:00
parent e4207e0120
commit 0a4d52ef03

View File

@@ -4,6 +4,7 @@ from base64 import b64decode
from io import BytesIO from io import BytesIO
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from matplotlib.figure import Figure
import numpy as np import numpy as np
from reportlab.lib import colors from reportlab.lib import colors
from reportlab.lib.pagesizes import letter, inch from reportlab.lib.pagesizes import letter, inch
@@ -177,7 +178,9 @@ def create_boards_pie_chart(data):
cmap = plt.get_cmap("Blues") cmap = plt.get_cmap("Blues")
cs = cmap(np.linspace(0.2, 0.8, num=len(num_bad_boards))) cs = cmap(np.linspace(0.2, 0.8, num=len(num_bad_boards)))
fig1, ax = plt.subplots() # fig, ax = plt.subplots() -> causes window resizing...
fig = Figure()
ax = fig.add_subplot()
ax.pie( ax.pie(
num_bad_boards, num_bad_boards,
labels=labels, labels=labels,
@@ -191,13 +194,12 @@ def create_boards_pie_chart(data):
ax.set_title("Broken Boards", fontsize=24, pad=20) ax.set_title("Broken Boards", fontsize=24, pad=20)
imgdata = BytesIO() imgdata = BytesIO()
fig1.savefig(imgdata, format="svg") fig.savefig(imgdata, format="svg")
imgdata.seek(0) # rewind the data imgdata.seek(0) # rewind the data
drawing = svg2rlg(imgdata) drawing = svg2rlg(imgdata)
imgdata.close() imgdata.close()
plt.close("all") plt.close("all")
pie_chart = KeepInFrame(375, 375, [Image(drawing)], hAlign="CENTER") pie_chart = KeepInFrame(375, 375, [Image(drawing)], hAlign="CENTER")
table_data = [labels, num_bad_boards] table_data = [labels, num_bad_boards]
t = Table(table_data) t = Table(table_data)