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

monthly_heatmap_detailedview function spine object has no attribute "get_color" #51

Open
BlackArbsCEO opened this issue Jul 22, 2024 · 5 comments

Comments

@BlackArbsCEO
Copy link

I'm attempting to use the new function qs.plots.monthly_returns_detailedview() and it's generating an error.

Python implementation: CPython
Python version       : 3.11.9
IPython version      : 8.25.0

numpy          : 1.26.4
matplotlib     : 3.8.4
seaborn        : 0.13.2
quantstats_lumi: 0.3.3
pandas         : 2.2.2

Compiler    : MSC v.1938 64 bit (AMD64)
OS          : Windows
Release     : 10
Machine     : AMD64
Processor   : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
CPU cores   : 12
Architecture: 64bit


### code ### 
# --------------

qs.plots.monthly_returns_detailedview(equity_df)
# equity_df is a pandas series with datetime index and price values from 2008-2024. 

### error ###
# -------------
C:\Users\kngka\miniconda3\envs\blk_ml_strats\Lib\site-packages\numpy\core\_methods.py:53: RuntimeWarning:

invalid value encountered in reduce

C:\Users\kngka\miniconda3\envs\blk_ml_strats\Lib\site-packages\matplotlib\colors.py:1371: RuntimeWarning:

invalid value encountered in divide

Traceback (most recent call last):
  File "D:\PERSONAL\CODE_PROJECTS\blk_ml_strats\blk_ml\evaluate_treasury_momo_strat.py", line 46, in <module>
    qs.plots.monthly_returns_detailedview(equity_df)
  File "C:\Users\kngka\miniconda3\envs\blk_ml_strats\Lib\site-packages\quantstats_lumi\_plotting\wrappers.py", line 1093, in monthly_returns_detailedview
    fig = _core.monthly_heatmap_detailedview(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kngka\miniconda3\envs\blk_ml_strats\Lib\site-packages\quantstats_lumi\_plotting\core.py", line 1266, in monthly_heatmap_detailedview
    return_color = cell.get_color()
                   ^^^^^^^^^^^^^^
AttributeError: 'Spine' object has no attribute 'get_color'. Did you mean: 'set_color'?
@grzesir
Copy link
Contributor

grzesir commented Jul 22, 2024

@twkim112 any ideas what this could be? I believe you changed this code recently

@twkim112
Copy link
Contributor

twkim112 commented Jul 23, 2024

Python version: 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:34:54) [Clang 16.0.6 ]

numpy          : 2.0.0
matplotlib     : 3.9.1
seaborn        : 0.13.2
pandas         : 2.2.2
quantstats_lumi: 0.3.1

I think I've found the source of the problem. When I call qs._plotting.core.monthly_heatmap_detailedview directly with the same data used in monthly_returns_detailedview, it works without errors. Here's what I observed:

>>> cell.get_color
Out[6]: <bound method Text.get_color of Text(8.5, 0.5, '349615008342768344328711938750155849728.00')>

>>> cell.get_color()
Out[7]: '.15'

I found bugs in wrapper function. I'll work on fixing this today.
@BlackArbsCEO Could you please try calling qs._plotting.core.monthly_heatmap_detailedview directly with the same data you used in monthly_returns_detailedview? This might help us isolate the issue.

@twkim112
Copy link
Contributor

twkim112 commented Jul 23, 2024

I created PR about wrapper function.
#52

@BlackArbsCEO
Copy link
Author

Python version: 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:34:54) [Clang 16.0.6 ]

numpy          : 2.0.0
matplotlib     : 3.9.1
seaborn        : 0.13.2
pandas         : 2.2.2
quantstats_lumi: 0.3.1

I think I've found the source of the problem. When I call qs._plotting.core.monthly_heatmap_detailedview directly with the same data used in monthly_returns_detailedview, it works without errors. Here's what I observed:

>>> cell.get_color
Out[6]: <bound method Text.get_color of Text(8.5, 0.5, '349615008342768344328711938750155849728.00')>

>>> cell.get_color()
Out[7]: '.15'

I found bugs in wrapper function. I'll work on fixing this today. @BlackArbsCEO Could you please try calling qs._plotting.core.monthly_heatmap_detailedview directly with the same data you used in monthly_returns_detailedview? This might help us isolate the issue.

I tried your suggestion and it did work correctly when I used qs._plotting.core.monthly_heatmap_detailedview directly.

@grzesir
Copy link
Contributor

grzesir commented Jul 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants