Skip to content

Commit af9e211

Browse files
committed
Save current figure
1 parent 3881d2c commit af9e211

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

040_ticker_plots

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def build_plot(cur_dict, ticker, shared_axis):
3232
ax.plot(current_df[cur_dict['date_field_name']],current_df[cur_dict['value_field_name']])
3333
ax.grid(True)
3434
ax.yaxis.set_major_locator(mticker.MaxNLocator(nbins='5', prune='upper'))
35-
plt.ylabel(cur_dict['y_label'])
35+
plt.ylabel(cur_dict['y_label'], rotation=0)
36+
# ax.text(0,0, cur_dict['y_label'], va='top', transform=ax.transAxes)
3637

3738
return ax
3839

@@ -57,23 +58,23 @@ pe_median_dict = {
5758
'path_prefixes' : './data/calculated_ratios/pe_median_',
5859
'date_field_name' : 'Date',
5960
'value_field_name' : 'PE_median',
60-
'y_label' : 'P/E median',
61+
'y_label' : 'P/E',
6162
'row_position' : 2,
6263
'rowspan' : 1
6364
}
6465
outstanding_shares_dict = {
6566
'path_prefixes' : './data/fundamentals/outstanding_shares_RAYMOND_',
6667
'date_field_name' : 'Date',
6768
'value_field_name' : 'Value',
68-
'y_label' : 'Outstanding shares',
69+
'y_label' : 'Outstanding \n shares',
6970
'row_position' : 3,
7071
'rowspan' : 1
7172
}
7273
closing_price_dict = {
7374
'path_prefixes' : ['./data/stock_prices/close_prices_pre_2016_02_', './data/stock_prices/close_prices_post_2016_02_'],
7475
'date_field_name' : 'Date',
7576
'value_field_name' : 'Close',
76-
'y_label' : 'Stock closing price',
77+
'y_label' : 'Stock \n closing price',
7778
'row_position' : 4,
7879
'rowspan' : 3
7980
}
@@ -102,9 +103,13 @@ def get_plt(dicts, ticker):
102103
plt.setp(ax_pe_median.get_xticklabels(), visible=False)
103104
plt.setp(ax_peg.get_xticklabels(), visible=False)
104105
plt.setp(ax_outstanding_shares.get_xticklabels(), visible=False)
105-
plt.subplots_adjust(left=.1,right=.96,top=.94,bottom=.16,hspace=0)
106+
plt.subplots_adjust(left=.16,right=.96,top=.94,bottom=.16,hspace=0)
106107

108+
ticker_fig = plt.gcf() # for "get current figure"
109+
ticker_fig.savefig('./graphs/'+ticker+'.png', dpi=300, format='png')
107110
return plt
108111

109-
aapl_plt = get_plt(dicts, 'AAPL')
110-
aapl_plt.show()
112+
ticker = 'AAPL'
113+
ticker_plt = get_plt(dicts, ticker)
114+
# ticker_plt.show()
115+

0 commit comments

Comments
 (0)