plotting 2 graphs fix

This commit is contained in:
dawoodkhan82 2020-08-31 12:54:14 -04:00
parent 0cd62350b5
commit 03dc7c1692
2 changed files with 4 additions and 3 deletions

View File

@ -9,14 +9,16 @@ def plot_forecast(final_year, companies, noise, show_legend, point_style):
x = np.arange(start_year, final_year + 1)
year_count = x.shape[0]
plt_format = ({"cross": "X", "line": "-", "circle": "o--"})[point_style]
fig = plt.figure()
ax = fig.add_subplot(1)
for i, company in enumerate(companies):
series = np.arange(0, year_count, dtype=float)
series = series ** 2 * (i + 1)
series += np.random.rand(year_count) * noise
plt.plot(x, series, plt_format)
ax.plot(x, series, plt_format)
if show_legend:
plt.legend(companies)
return plt
return fig
gr.Interface(plot_forecast,

View File

@ -32,7 +32,6 @@ def encode_plot_to_base64(plt):
with BytesIO() as output_bytes:
plt.savefig(output_bytes, format="png")
bytes_data = output_bytes.getvalue()
plt.close()
base64_str = str(base64.b64encode(bytes_data), 'utf-8')
return "data:image/png;base64," + base64_str