Skip to content

Commit

Permalink
removed spines from plots
Browse files Browse the repository at this point in the history
  • Loading branch information
ranaroussi committed Oct 5, 2019
1 parent 44cbf7f commit 1807f12
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
33 changes: 33 additions & 0 deletions quantstats/_plotting/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def plot_returns_bars(returns, benchmark=None,
# ---------------

fig, ax = _plt.subplots(figsize=figsize)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)

# use a more precise date string for the x axis locations in the toolbar
fig.suptitle(title+"\n", y=.99, fontweight="bold", fontname=fontname,
Expand Down Expand Up @@ -212,6 +216,11 @@ def plot_timeseries(returns, benchmark=None,
# ---------------

fig, ax = _plt.subplots(figsize=figsize)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)

fig.suptitle(title+"\n", y=.99, fontweight="bold", fontname=fontname,
fontsize=14, color="black")

Expand Down Expand Up @@ -308,6 +317,11 @@ def plot_histogram(returns, resample="M", bins=20,
apply_fnc).resample(resample).last()

fig, ax = _plt.subplots(figsize=figsize)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)

fig.suptitle(title+"\n", y=.99, fontweight="bold", fontname=fontname,
fontsize=14, color="black")

Expand Down Expand Up @@ -383,6 +397,10 @@ def plot_rolling_stats(returns, benchmark=None, title="",
colors, _, _ = _get_colors(grayscale)

fig, ax = _plt.subplots(figsize=figsize)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)

df = _pd.DataFrame(index=returns.index, data={returns_label: returns})
if isinstance(benchmark, _pd.Series):
Expand Down Expand Up @@ -461,6 +479,11 @@ def plot_rolling_beta(returns, benchmark,
colors, _, _ = _get_colors(grayscale)

fig, ax = _plt.subplots(figsize=figsize)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)

fig.suptitle(title+"\n", y=.99, fontweight="bold", fontname=fontname,
fontsize=14, color="black")

Expand Down Expand Up @@ -541,6 +564,11 @@ def plot_longest_drawdowns(returns, periods=5, lw=1.5,
by='days', ascending=False, kind='mergesort')[:periods]

fig, ax = _plt.subplots(figsize=figsize)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)

fig.suptitle("Top %.0f Drawdown Periods\n" %
periods, y=.99, fontweight="bold", fontname=fontname,
fontsize=14, color="black")
Expand Down Expand Up @@ -638,6 +666,11 @@ def plot_distribution(returns, figsize=(10, 6),
port['Yearly'].ffill(inplace=True)

fig, ax = _plt.subplots(figsize=figsize)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)

fig.suptitle("Return Quantiles\n", y=.99,
fontweight="bold", fontname=fontname,
fontsize=14, color="black")
Expand Down
10 changes: 10 additions & 0 deletions quantstats/_plotting/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ def earnings(returns, start_balance=1e5, mode="comp",
figsize = (size[0], size[0]*.55)

fig, ax = _plt.subplots(figsize=figsize)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)

fig.suptitle(title, fontsize=14, y=.995,
fontname=fontname, fontweight='bold', color='black')

Expand Down Expand Up @@ -575,6 +580,11 @@ def monthly_heatmap(returns, annot_size=10, figsize=(10, 5),
figsize = (figsize[0]*1.04, max([fig_height, figsize[1]]))

fig, ax = _plt.subplots(figsize=figsize)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)

fig.set_facecolor('white')
ax.set_facecolor('white')

Expand Down

0 comments on commit 1807f12

Please sign in to comment.