Skip to content

Commit

Permalink
removed obsolete imports, added tests, and plot_contours accepts leve…
Browse files Browse the repository at this point in the history
…ls='legacy'
  • Loading branch information
cwehmeyer committed Jun 19, 2018
1 parent f8021e7 commit a49ff07
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
1 change: 0 additions & 1 deletion pyemma/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
from .plots2d import plot_density
from .plots2d import plot_free_energy
from .plots2d import plot_contour
from .plots2d import plot_scatter_contour
from .networks import plot_markov_model, plot_flux, plot_network, NetworkPlot
from .markovtests import plot_cktest
from .thermoplots import *
Expand Down
11 changes: 6 additions & 5 deletions pyemma/plots/plots2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def contour(
vmin, vmax = zlim
_, ax, _ = plot_contour(
x, y, z, ax=ax, cmap=cmap,
ncontours=ncontours, vmin=vmin, vmax=vmax, levels=None,
ncontours=ncontours, vmin=vmin, vmax=vmax, levels='legacy',
cbar=colorbar, cax=None, cbar_label=None, logscale=False,
nbins=100, method=method)
return ax
Expand Down Expand Up @@ -232,7 +232,7 @@ def _to_free_energy(z, minener_zero=False):
def plot_map(
x, y, z, ax=None, cmap=None,
ncontours=100, vmin=None, vmax=None, levels=None,
cbar=True, cax=None, cbar_label=None, logscale=False):
cbar=True, cax=None, cbar_label=None, norm=None):
"""Plot a two-dimensional map from data on a grid.
Parameters
Expand Down Expand Up @@ -262,8 +262,8 @@ def plot_map(
stealing space from ax.
cbar_label : str, optional, default=None
Colorbar label string; use None to suppress it.
logscale : boolean, optional, default=False
Plot the z-values in logscale.
norm : matplotlib norm, optional, default=None
Use a norm when coloring the contour plot.
Returns
-------
Expand Down Expand Up @@ -511,7 +511,8 @@ def plot_contour(
vmax : float, optional, default=None
Highest z-value to be plotted.
levels : iterable of float, optional, default=None
Contour levels to plot.
Contour levels to plot; use legacy style calculation
if 'legacy'.
cbar : boolean, optional, default=True
Plot a color bar.
cax : matplotlib.Axes object, optional, default=None
Expand Down
16 changes: 15 additions & 1 deletion pyemma/plots/tests/test_plots2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,30 @@ def test_free_energy(self):

def test_contour(self):
contour(self.data[:,0], self.data[:,1], self.data[:,0])
contour(
self.data[:,0], self.data[:,1], self.data[:,0],
zlim=(self.data[:, 0].min(), self.data[:, 0].max()))

def test_scatter_contour(self):
scatter_contour(self.data[:,0], self.data[:,1], self.data[:,0])

def test_plot_density(self):
plot_density(self.data[:, 0], self.data[:, 1])
plot_density(
self.data[:, 0], self.data[:, 1], logscale=True)
plot_density(
self.data[:, 0], self.data[:, 1], logscale=False)

def test_plot_free_energy(self):
plot_free_energy(
self.data[:, 0], self.data[:, 1], legacy=False)
with self.assertRaises(ValueError):
plot_free_energy(
self.data[:, 0], self.data[:, 1],
legacy=False, offset=42)
with self.assertRaises(ValueError):
plot_free_energy(
self.data[:, 0], self.data[:, 1],
legacy=False, ncountours=42)

def test_plot_contour(self):
plot_contour(self.data[:, 0], self.data[:, 1], self.data[:,0])

0 comments on commit a49ff07

Please sign in to comment.