diff options
Diffstat (limited to 'python/exploration/marketing.py')
| -rw-r--r-- | python/exploration/marketing.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/python/exploration/marketing.py b/python/exploration/marketing.py index d14d75b6..a3f5f3b2 100644 --- a/python/exploration/marketing.py +++ b/python/exploration/marketing.py @@ -13,11 +13,23 @@ def run_scenario(pool_size, rho, successprob, issuerweights, amount): df = pd.DataFrame(S.flatten(), columns=['Probability'], index=raised) return df -def plot_scenarios(df, pool_size): +def plot_scenarios(df, bins = [0,0.1, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 2000]): ''' takes run_scenario df ''' - bins = [0,0.01,50,100,150,200,250,300,350,400,450,500,pool_size] - df1 = df.groupby(pd.cut(df.index,bins,right=False)).sum() + df1 = df.groupby(pd.cut(df.index, bins, right=False)).sum() + #have to manually label or else we lose ordering + bins_label = [] + for this, next in zip(bins, bins[1:]): + bins_label.append(str(this) + " to " + str(next)) + bins_label[0] = 'none' + label = pd.DataFrame(bins_label, index=df1.index, columns=['bin']) + df1 = df1.join(label).set_index('bin') ax = df1.plot(kind='bar') + + ax.legend().remove() + ax.set_xlabel('Raised AUM (mm)') + ax.set_ylabel('Probability (%)') + y_ticks = ax.get_yticks() + ax.set_yticklabels(['{:.0f}%'.format(y*100) for y in y_ticks]) plt.pyplot.tight_layout() return ax @@ -34,3 +46,4 @@ def plot_prob_over(df): def add_to_plot(df, ax): ax.plot(1-df.cumsum()) return ax + |
