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

Updated docs + made mpl swatch look more similar to bokeh swatch #2

Merged
merged 15 commits into from
Nov 22, 2019
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
8 changes: 8 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- Thank you for the PR! We recommend titling it the same as your colormap -->
PR Checklist:
- [ ] comma-separated file of RGB values
- [ ] Jupyter notebook with the same name as the colormap.
- [ ] The notebook contains:
- [ ] an explanation of the colormap
- [ ] a color swatch
- [ ] an example of using the colormap
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ __pycache__
pip-wheel-metadata
**.ipynb_checkpoints
__pycache__/

.vscode/*
*.code-workspace
# nbsite
# these files normally shouldn't be checked in as they should be
# dynamically built from notebooks
Expand Down
29 changes: 12 additions & 17 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
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 explanation of the colormap - what is it? and when/why would someone use it?
3. a swatch of the colormap - we recommend using our [swatch function](colormaps/index.ipynb), but it's not required
3. at least one example plot using the colormap - it can be exclusively Bokeh, Matplotlib, or Holoviews

You can use this sample pull request as a model: [#3](https://github.com/pyviz/contrib_colormaps/pull/3)

## 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).
22 changes: 14 additions & 8 deletions contrib_colormaps/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,30 @@

array = np.meshgrid(np.linspace(0, 1, 256), np.linspace(0, 1, 10))[0]

def swatch(name, bounds=None, array=array, **kwargs):
def swatch(name, bounds=None, array=array, aspect=10, **kwargs):
"""Show swatch using matplotlib or bokeh via holoviews"""
if bounds is None:
bounds = (0, 0, 256, 1)

plot = hv.Image(array, bounds=bounds, group=name)
backends = hv.Store.loaded_backends()
if 'bokeh' in backends:
width = kwargs.pop('width', 900)
height = kwargs.pop('height', 100)
plot.opts(opts.Image(backend='bokeh', width=width, height=height, toolbar='above',
default_tools=['xwheel_zoom', 'xpan', 'save', 'reset'],
frame_height = kwargs.pop('frame_height', 60)
plot.opts(opts.Image(backend='bokeh', aspect=aspect, frame_height=frame_height,
toolbar='above', 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)
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')

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

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

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


Expand Down
11 changes: 11 additions & 0 deletions doc/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
div.body {
max-width: 80%;
}

div.document {
margin: 30px auto 0 5%;
}

div.footer {
width: 90%;
}
17 changes: 15 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
version = release = contrib_colormaps.__version__

html_static_path += ['_static']
html_favicon = 'favicon.ico'
html_favicon = '_static/favicon.ico'
html_theme_options = {
'logo': 'logo.png',
'logo_name': True,
'page_width': '90%',
'page_width': '100%',
'font_family': "Ubuntu, sans-serif",
'font_size': '0.9em',
'link': '#347ab4',
Expand All @@ -25,6 +25,19 @@
'show_powered_by': False,
}

extensions += ['nbsite.gallery']

nbsite_gallery_conf = {
'github_org': 'pyviz',
'github_project': 'contrib_colormaps',
'galleries': {
'colormaps': {
'title': 'Colormaps',
'intro': 'Gallery of colormaps included in contrib_colormaps'
}
},
}

html_context.update({
'PROJECT': project,
'DESCRIPTION': description,
Expand Down
24 changes: 24 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
..
Originally generated by nbsite (0.6.3):
/Users/jsignell/conda/envs/cc_dev/bin/nbsite generate-rst --org pyviz --project-name contrib_colormaps --offset 0
Will not subsequently be overwritten by nbsite, so can be edited.

*****************
Contrib Colormaps
*****************

.. notebook:: contrib_colormaps ../examples/index.ipynb
:offset: 0

.. toctree::
:titlesonly:
:maxdepth: 2
:hidden:

Introduction <self>
Colormaps <colormaps/index>


-------

`Right click to download this notebook from GitHub. <https://raw.githubusercontent.com/pyviz/contrib_colormaps/master/examples/index.ipynb>`_
4 changes: 2 additions & 2 deletions dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

$ doit list

To run one command, for instance building the website, run:
To run one command, for instance building the docs, run:

$ doit build_website
$ doit build_docs
"""

from pyctdev import * # noqa: api
Expand Down
136 changes: 0 additions & 136 deletions examples/colormaps/index.ipynb

This file was deleted.

Loading