Skip to content

Commit

Permalink
hooks + doc amends
Browse files Browse the repository at this point in the history
  • Loading branch information
story645 committed Nov 7, 2019
1 parent 34d35f9 commit 204185e
Show file tree
Hide file tree
Showing 4 changed files with 2,815 additions and 148 deletions.
25 changes: 10 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,26 @@ pip install contrib_colormaps

## Contributing

To add a colormap, open a pull request on this repository adding a
comma-separated file of RGB values to the contrib_colormaps/colormaps
To add a colormap, open a pull request on this repository adding the following files:

1. comma-separated file of RGB values to the contrib_colormaps/colormaps
directory. This file should look like:

```
0,0.20755,0.97632
0,0.22113,0.96201
```

This PR should also include a new notebook in
[examples/colormaps](examples/colormaps) with a name that matches the
name of the csv (e.g. for a new colormap called 'rainforest' with a csv
'rainforest.csv' there should be a corresponding 'rainforest.ipynb').
2. A Jupyter notebook in[examples/colormaps](examples/colormaps) meeting the following criteria:

The last requirement is that you regenerate the baseline images used for tests.
First make sure you have holoviews, matplotlib, and pytest-mpl in your
environment. Then change directories into tests, and regenerate the plots

```
cd contrib_colorcets/tests
pytest --mpl-generate-path=baseline
```
1. a name that matches the
name of the csv
e.g. for a new colormap called 'rainforest' with a csv 'rainforest.csv' there should be a corresponding 'rainforest.ipynb'
2. an explaination of the colormap
3. a swatch of the colormap
3. at least one example plot using the colormap


## About PyViz

contrib_colormaps is part of the PyViz initiative for making Python-based
visualization tools work well together. See [pyviz.org](http://pyviz.org).
14 changes: 10 additions & 4 deletions contrib_colormaps/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ def swatch(name, bounds=None, array=array, **kwargs):
default_tools=['xwheel_zoom', 'xpan', 'save', 'reset'],
cmap=palette[name]))
if 'matplotlib' in backends:
aspect = kwargs.pop('aspect', 15)
fig_size = kwargs.pop('fig_size',350)
plot.opts(opts.Image(backend='matplotlib', aspect=aspect, fig_size=fig_size,
cmap=cm[name]))
def hook(plot, element):
plot.handles['axis'].axis('off')
plot.handles['axis'].set_title("sample", loc='left',
fontfamily='DejaVu Sans', fontsize=14,
fontweight='roman',fontstretch='semi-expanded')

aspect = kwargs.pop('aspect', 10)
fig_size = kwargs.pop('fig_size',300)

plot.opts(opts.Image(backend='matplotlib', aspect=aspect, fig_size=fig_size, title="", cmap=cm[name], hooks=[hook]))

return plot.opts(opts.Image(xaxis=None, yaxis=None), opts.Image(**kwargs))

Expand Down
170 changes: 68 additions & 102 deletions examples/colormaps/index.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 204185e

Please sign in to comment.