diff options
Diffstat (limited to 'python/graphics.py')
| -rw-r--r-- | python/graphics.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/python/graphics.py b/python/graphics.py index 3a88147a..f9935b5d 100644 --- a/python/graphics.py +++ b/python/graphics.py @@ -55,7 +55,7 @@ def shiftedColorMap(cmap, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap'): return newcmap -def plot_time_color_map(df, spread_shock, attr="pnl", path=".", color_map=cm.RdYlGn, index='IG'): +def plot_time_color_map(df, spread_shock, attr="pnl", path=".", color_map=cm.RdYlGn, index='IG', centered = True): val_date = df.index[0].date() df = df.reset_index() @@ -67,8 +67,11 @@ def plot_time_color_map(df, spread_shock, attr="pnl", path=".", color_map=cm.RdY #plt.style.use('seaborn-whitegrid') fig, ax = plt.subplots() series = df[attr] - midpoint = 1 - series.max() / (series.max() + abs(series.min())) - shifted_cmap = shiftedColorMap(color_map, midpoint=midpoint, name='shifted') + if centered is True: + midpoint = 1 - series.max() / (series.max() + abs(series.min())) + shifted_cmap = shiftedColorMap(color_map, midpoint=midpoint, name='shifted') + else: + shifted_cmap = color_map chart = ax.imshow(series.values.reshape(date_range.size, spread_shock.size).T, extent=(date_range.min(), date_range.max(), |
