Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 0.0 when there is no trade, sams as monthly_heatmap_detailedview #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions quantstats_lumi/_plotting/wrappers.py
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

category Error Handling

The code uses bare except clauses in a couple of places to catch all exceptions without specifying the exception type. This can make it difficult to identify and handle specific types of exceptions. Consider replacing the bare except clauses with specific exception types that you expect and want to handle, such as ValueError, KeyError, etc. This will make the exception handling more explicit and allow you to handle different exceptions appropriately.

Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ def monthly_heatmap(
cmap = "gray" if grayscale else "RdYlGn"

returns = _stats.monthly_returns(returns, eoy=eoy, compounded=compounded) * 100
mask = returns.map(lambda x: x == 0)

fig_height = len(returns) / 2.5

Expand Down Expand Up @@ -983,6 +984,7 @@ def monthly_heatmap(
cbar=cbar,
cmap=cmap,
cbar_kws={"format": "%.0f%%"},
mask=mask,
)
else:
ax.set_title(
Expand All @@ -1005,6 +1007,7 @@ def monthly_heatmap(
cbar=cbar,
cmap=cmap,
cbar_kws={"format": "%.0f%%"},
mask=mask,
)
# _sns.set(font_scale=1)

Expand All @@ -1017,6 +1020,8 @@ def monthly_heatmap(
_plt.xticks(rotation=0, fontsize=annot_size * 1.2)
_plt.yticks(rotation=0, fontsize=annot_size * 1.2)

plt.grid(False)

try:
_plt.subplots_adjust(hspace=0, bottom=0, top=1)
except Exception:
Expand Down