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 flat argument from plot, solves https://github.com/CamDavidson… #264

Merged
merged 1 commit into from
Dec 12, 2016
Merged
Show file tree
Hide file tree
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
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