Spaces:
Runtime error
Runtime error
Upload tool.py
Browse files
tool.py
CHANGED
@@ -384,22 +384,22 @@ def plot_stock_data(stock_data: pd.DataFrame, ax: Optional[plt.Axes] = None, fig
|
|
384 |
|
385 |
ax.annotate(unchanged_var + ':' + str(round(start_y, 2)) + ' @' + start_x_dim, xy=(start_x_dim, start_y),
|
386 |
xytext=(start_x_dim, start_y),
|
387 |
-
textcoords='data', fontsize=14,color=color, horizontalalignment='right')
|
388 |
|
389 |
ax.annotate(unchanged_var + ':' + str(round(end_y, 2)) +' @' + end_x_dim, xy=(end_x_dim, end_y),
|
390 |
xytext=(end_x_dim, end_y),
|
391 |
-
textcoords='data', fontsize=14, color=color, horizontalalignment='left')
|
392 |
|
393 |
|
394 |
elif figure_type == 'bar':
|
395 |
ax.bar(x_dim, stock_data.iloc[:, 2], label = unchanged_var + '_' + index_name, width=0.3, color=color)
|
396 |
ax.annotate(unchanged_var + ':' + str(round(start_y, 2)) + ' @' + start_x_dim, xy=(start_x_dim, start_y),
|
397 |
xytext=(start_x_dim, start_y),
|
398 |
-
textcoords='data', fontsize=14, color=color, horizontalalignment='right')
|
399 |
|
400 |
ax.annotate(unchanged_var + ':' + str(round(end_y, 2)) + ' @' + end_x_dim, xy=(end_x_dim, end_y),
|
401 |
xytext=(end_x_dim, end_y),
|
402 |
-
textcoords='data', fontsize=14, color=color, horizontalalignment='left')
|
403 |
|
404 |
plt.xticks(x_dim,rotation=45) #
|
405 |
ax.xaxis.set_major_locator(MaxNLocator( integer=True, prune=None, nbins=100)) #
|
@@ -409,7 +409,7 @@ def plot_stock_data(stock_data: pd.DataFrame, ax: Optional[plt.Axes] = None, fig
|
|
409 |
plt.ylabel(f'{index_name}', fontproperties=font_prop,fontsize=16)
|
410 |
ax.set_title(title_name , fontproperties=font_prop,fontsize=16)
|
411 |
plt.legend() # 显示图例
|
412 |
-
fig = plt.gcf()
|
413 |
fig.set_size_inches(18, 12)
|
414 |
|
415 |
return ax
|
|
|
384 |
|
385 |
ax.annotate(unchanged_var + ':' + str(round(start_y, 2)) + ' @' + start_x_dim, xy=(start_x_dim, start_y),
|
386 |
xytext=(start_x_dim, start_y),
|
387 |
+
textcoords='data', fontsize=14,color=color, horizontalalignment='right',fontproperties=font_prop)
|
388 |
|
389 |
ax.annotate(unchanged_var + ':' + str(round(end_y, 2)) +' @' + end_x_dim, xy=(end_x_dim, end_y),
|
390 |
xytext=(end_x_dim, end_y),
|
391 |
+
textcoords='data', fontsize=14, color=color, horizontalalignment='left',fontproperties=font_prop)
|
392 |
|
393 |
|
394 |
elif figure_type == 'bar':
|
395 |
ax.bar(x_dim, stock_data.iloc[:, 2], label = unchanged_var + '_' + index_name, width=0.3, color=color)
|
396 |
ax.annotate(unchanged_var + ':' + str(round(start_y, 2)) + ' @' + start_x_dim, xy=(start_x_dim, start_y),
|
397 |
xytext=(start_x_dim, start_y),
|
398 |
+
textcoords='data', fontsize=14, color=color, horizontalalignment='right',fontproperties=font_prop)
|
399 |
|
400 |
ax.annotate(unchanged_var + ':' + str(round(end_y, 2)) + ' @' + end_x_dim, xy=(end_x_dim, end_y),
|
401 |
xytext=(end_x_dim, end_y),
|
402 |
+
textcoords='data', fontsize=14, color=color, horizontalalignment='left',fontproperties=font_prop)
|
403 |
|
404 |
plt.xticks(x_dim,rotation=45) #
|
405 |
ax.xaxis.set_major_locator(MaxNLocator( integer=True, prune=None, nbins=100)) #
|
|
|
409 |
plt.ylabel(f'{index_name}', fontproperties=font_prop,fontsize=16)
|
410 |
ax.set_title(title_name , fontproperties=font_prop,fontsize=16)
|
411 |
plt.legend() # 显示图例
|
412 |
+
fig = plt.gcf(prop=font_properties)
|
413 |
fig.set_size_inches(18, 12)
|
414 |
|
415 |
return ax
|