Skip to content

Commit

Permalink
Merge pull request #264 from CamDavidsonPilon/remove-flat-arg
Browse files Browse the repository at this point in the history
remove flat argument from plot, solves https://github.com/CamDavidson…
  • Loading branch information
CamDavidsonPilon committed Dec 12, 2016
2 parents e909832 + 6d8ed87 commit 96ca3d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#### 0.9.3 (in dev)
- adding `plot_loglogs` to `KaplanMeierFitter`
- removing `flat` argument in `plot` methods. It was causing confusion. To replicate it, one can set `ci_force_lines=True` and `show_censors=True`.

#### 0.9.2
- deprecates Pandas versions before 0.18.
Expand Down
9 changes: 1 addition & 8 deletions lifelines/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ def plot_estimate(cls, estimate):
Matplotlib plot arguments can be passed in inside the kwargs, plus
Parameters:
flat: an opiniated design style with stepped lines and no shading.
Similar to R's plotting. Default: False
show_censors: place markers at censorship events. Default: False
censor_styles: If show_censors, this dictionary will be passed into
the plot call.
Expand All @@ -326,7 +324,7 @@ def plot_estimate(cls, estimate):
ax: a pyplot axis object
""" % estimate

def plot(ix=None, iloc=None, flat=False, show_censors=False,
def plot(ix=None, iloc=None, show_censors=False,
censor_styles=None, ci_legend=False, ci_force_lines=False,
ci_alpha=0.25, ci_show=True, at_risk_counts=False,
bandwidth=None, **kwargs):
Expand All @@ -341,11 +339,6 @@ def plot(ix=None, iloc=None, flat=False, show_censors=False,
set_kwargs_color(kwargs)
set_kwargs_drawstyle(kwargs)

# R-style graphics
if flat:
ci_force_lines = True
show_censors = True

if estimate == "hazard_":
if bandwidth is None:
raise ValueError('Must specify a bandwidth parameter in the call to plot_hazard.')
Expand Down
18 changes: 3 additions & 15 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,11 @@ def test_show_censor_with_index_0(self, block, kmf):
self.plt.show(block=block)
return

def test_flat_style_and_marker(self, block, kmf):
data1 = np.random.exponential(10, size=200)
data2 = np.random.exponential(2, size=200)
C1 = np.random.binomial(1, 0.9, size=200)
C2 = np.random.binomial(1, 0.95, size=200)
kmf.fit(data1, C1, label='test label 1')
ax = kmf.plot(flat=True, censor_styles={'marker': '+', 'mew': 2, 'ms': 7})
kmf.fit(data2, C2, label='test label 2')
kmf.plot(ax=ax, censor_styles={'marker': 'o', 'ms': 7}, flat=True)
self.plt.title("testing kmf flat styling + marker")
self.plt.show(block=block)
return

def test_flat_style_no_censor(self, block, kmf):
def test_flat_style_with_customer_censor_styles(self, block, kmf):
data1 = np.random.exponential(10, size=200)
kmf.fit(data1, label='test label 1')
kmf.plot(flat=True, censor_styles={'marker': '+', 'mew': 2, 'ms': 7})
kmf.plot(ci_force_lines=True, show_censors=True,
censor_styles={'marker': '+', 'mew': 2, 'ms': 7})
self.plt.title('test_flat_style_no_censor')
self.plt.show(block=block)
return
Expand Down

0 comments on commit 96ca3d4

Please sign in to comment.