Skip to content

Commit

Permalink
Fix #2590: Created new axes for plot of persistence_length. (#2591)
Browse files Browse the repository at this point in the history
* Fixes #2590
* Created new axes for plot of persistence_length if ax is not passed in as an argument (analysis/polymer.py)
* Added test (analysis/test_persistencelength.py)
  • Loading branch information
ss62171 authored Mar 21, 2020
1 parent 4102481 commit 9a0a657
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Enhancements
* Improve the distance search in water bridge analysis with capped_distance (PR #2480)
* Added weights_groupselections option in RMSD for mapping custom weights
to groupselections (PR #2610, Issue #2429)
* PersistenceLength.plot() now create new axes if current axes not provided (Issue #2590)

Changes
* Removed `details` from `ClusteringMethod`s (Issue #2575, PR #2620)
Expand Down
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/polymer.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def plot(self, ax=None):
"""
import matplotlib.pyplot as plt
if ax is None:
ax = plt.gca()
fig, ax = plt.subplots()
ax.plot(self.x, self.results, 'ro', label='Result')
ax.plot(self.x, self.fit, label='Fit')
ax.set_xlabel(r'x')
Expand Down
5 changes: 5 additions & 0 deletions testsuite/MDAnalysisTests/analysis/test_persistencelength.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def test_plot_with_ax(self, p_run):
ax2 = p_run.plot(ax=ax)

assert ax2 is ax

def test_current_axes(self, p_run):
fig, ax = plt.subplots()
ax2 = p_run.plot(ax=None)
assert ax2 is not ax


class TestFitExponential(object):
Expand Down

0 comments on commit 9a0a657

Please sign in to comment.