Skip to content
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 .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dask-worker-space
# netcdf outputs
*nc
.pytest_cache

contact_map/version.py
cover
Expand Down
20 changes: 15 additions & 5 deletions contact_map/concurrence.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,12 @@ def x_values(self):
def x_values(self, x_values):
self._x_values = x_values

def plot(self, concurrence=None):
def plot(self, concurrence=None, **kwargs):
"""Contact concurrence plot based on matplotlib

Additional kwargs given here will be passed to the matplotlib
``Axes.plot()`` method.

Parameters
----------
concurrence : :class:`.Concurrence`
Expand All @@ -249,23 +252,30 @@ def plot(self, concurrence=None):
fig = plt.figure(1)
ax = fig.add_subplot(111)

plot_kwargs = {'markersize': 1}
plot_kwargs.update(kwargs)

y_val = -1.0
for label, val_set in zip(labels, concurrence.values):
x_vals = [x for (x, y) in zip(x_values, val_set) if y]
ax.plot(x_vals, [y_val] * len(x_vals), '.', markersize=1,
label=label)
ax.plot(x_vals, [y_val] * len(x_vals), '.', label=label,
**plot_kwargs)
y_val -= 1.0

ax.set_ylim(top=0.0)
ax.set_xlim(left=min(x_values), right=max(x_values))
ax.set_yticks([])
lgd = ax.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
return (fig, ax, lgd)


def plot_concurrence(concurrence, labels=None, x_values=None): # -no-cov-
def plot_concurrence(concurrence, labels=None, x_values=None, **kwargs): # -no-cov-
"""
Convenience function for concurrence plots.

Additional kwargs given here will be passed to the matplotlib
``Axes.plot()`` method.

Parameters
----------
concurrence : :class:`.Concurrence`
Expand All @@ -279,4 +289,4 @@ def plot_concurrence(concurrence, labels=None, x_values=None): # -no-cov-
--------
:class:`.ConcurrencePlotter`
"""
return ConcurrencePlotter(concurrence, labels, x_values).plot()
return ConcurrencePlotter(concurrence, labels, x_values).plot(**kwargs)
6 changes: 4 additions & 2 deletions docs/examples/index.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Examples
========

So far, we only have one major example. We will add others here as they
are written.
We have several examples to illustrate various features of the code. These
notebooks have been rendered here for the web, but the originals are
found in the ``examples/`` directory of the package, and you can run them
yourself!

.. toctree::
:maxdepth: 1
Expand Down
13 changes: 13 additions & 0 deletions docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ This is a three-step process:
interpreted uses) and the ``.`` tells it to find ``setup.py`` in the
current directory.

Additional functionality
========================

Installing some additional packages will immediately enable additional
features in ``contact_map``. To get all the functionality, install the
packages in ``optional_installs.txt``, either with ``pip install -r
optional_installs.txt`` or ``conda install -y --file
optional_installs.txt``.

Specific extra functionality that can be enabled:

* plotting tools (install ``matplotlib``)
* parallelization (install ``dask``, ``distributed``)

Testing your installation
=========================
Expand Down
232 changes: 232 additions & 0 deletions examples/concurrences.ipynb

Large diffs are not rendered by default.

Binary file added examples/data/gsk3b_example.h5
Binary file not shown.