deepcharles / ruptures

ruptures: change point detection in Python
BSD 2-Clause "Simplified" License
1.59k stars 162 forks source link

feat(display): more display options #160

Closed earthgecko closed 3 years ago

earthgecko commented 3 years ago

Firstly thanks for a cool library. The following proposed change is cosmetic only.

The current display plot of the computed_chg_pts renders the dashed vertical dashed lines with linewidth=3 and no alpha. This results in the dashed vertical lines overlaying the signal and obscuring it.

rpt.display(signal, results, computed_chg_pts, figsize=(8, 4))

image Please note these example plots are not broken, they are using a modified results list with only results from a specific window plotted, they are just highlighting a specific change point in a defined period, hence no leading change points or trailing change points are plotted.

The proposed change allows the user to pass additional arguments that allow the user to format the computed_chg_pts axvline parameters to overcome this resulting in a clearer visualisation of the change point and the signal.

rpt.display(
    signal, results, computed_chg_pts, computed_chg_pts_linewidth=1,
    computed_chg_pts_alpha=0.3, figsize=(8, 4))

image

The change maintains the current format as the default behaviour and is therefore backwards compatible.

codecov[bot] commented 3 years ago

Codecov Report

Merging #160 (26a3dd8) into master (bba0a08) will increase coverage by 0.29%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #160      +/-   ##
==========================================
+ Coverage   96.01%   96.31%   +0.29%     
==========================================
  Files          40       40              
  Lines         979      976       -3     
==========================================
  Hits          940      940              
+ Misses         39       36       -3     
Impacted Files Coverage Δ
src/ruptures/show/display.py 32.35% <100.00%> (+2.62%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update bba0a08...26a3dd8. Read the comment docs.

earthgecko commented 3 years ago

Hi @deepcharles done I think. I wrapped the docstrings too as the function comment is wrapped.

earthgecko commented 3 years ago

Added to tests and I think I resolved codecov no tests for color, etc by using the function arguments directly, rather than redeclaring them.

deepcharles commented 3 years ago

very nice, I'll take a look

deepcharles commented 3 years ago

Sorry, I forgot to merge. Thanks for your work.