Git Product home page Git Product logo

palettable's Introduction

Palettable

Build Status

Coveralls

Latest Version

Supported Python versions

Wheel Status

Color Palettes for Python

Palettable (formerly brewer2mpl) is a library of color palettes for Python. It's written in pure Python with no dependencies, but it can supply color maps for matplotlib. You can use Palettable to customize matplotlib plots or supply colors for a web application.

For more information see the documentation.

palettable's People

Contributors

andy-esch avatar appleparan avatar asottile avatar astrofrog avatar chebee7i avatar embray avatar jiffyclub avatar jonathansick avatar mbforbes avatar penguinpee avatar poke1024 avatar tomdlt avatar wch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

palettable's Issues

Add option of building custom colormap from HEX

Hi,
I can't seem to find any option of building a custom color palette from hex codes, is there any?

An example from matplotlib

from matplotlib.colors import ListedColormap

newcmp = ListedColormap(['#2352DF','#829DED','#B8C7F5','#DBE3FA','#FBF9F9','#FED7D7','#FEAFAF','#FE7171','#C30303'])

Brown sequential colorbrewer

Would you be able to add a brown sequential colorbrewer scale? It's available in the diverging color scale but not in the sequential.

The closest I could find is Yellow/Orange/Brown but it's awkward for the low end of precipitation quantities, which should just be brown.

I'd contribute it myself but I'm not sure if you have a quick and/or automated way of producing these colors.

Thanks!

Pip install issue

In trying to install, I receive an error "Could not fetch URL https://pypi.python.org/simple/palattable/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) - skipping"

Could not find a version that satisfies the requirement palattable (from versions: )
No matching distribution found for palattable

Any suggestions?

Add gallery page

Glancing at the docs, it's hard to get a broad sense of what color schemes are available without hunting around. It would be helpful to have a gallery of color schemes (and possibly the tumblrs from where they came from!) on the landing page.

Add import functionality for act and cbt color swatches?

Hi!

I have some code to import color swatches from NCAR and NASA in the cbt and act formats. Would you be interested if I submitted this as a pull request? It seems like the functionality would fit better as an io module in palettable than a separate project...

pip install failed

>> pip install brewer2mpl
Downloading/unpacking brewer2mpl
  Downloading brewer2mpl-1.3.2.tar.gz
  Running setup.py egg_info for package brewer2mpl
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/home/tomek/.virtualenv/trololo/build/brewer2mpl/setup.py", line 4, in <module>
        with open('README.rst', 'r') as f:
    IOError: [Errno 2] No such file or directory: 'README.rst'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/home/tomek/.virtualenv/trololo/build/brewer2mpl/setup.py", line 4, in <module>

    with open('README.rst', 'r') as f:

IOError: [Errno 2] No such file or directory: 'README.rst'

Python 3.8 installing from pip

Hi, is there any reason to not add Python 3.8 to the setup.py version list? As it is, pip doesn't find it when using 3.8 since it only lists up to 3.7

Merge cubehelix into palettable

I'm often importing both palettable for the qualitative/divergent maps and cubehelix from @jradavenport for continuous maps in my plotting projects. I was wondering: could we merge the cubehelix smarts into palettable?

I think the ideal implementation would be to make a cubehelix sub package containing a Cubehelix subclass of Palettable.

Cubehelix.__init__() would take the same arguments as cubehelix.cmap allowing a person to make an arbitrary cubehelix map.

The cubehelix sub package would also include several pre-baked cubehelix maps, like the colorbrewer and tableau sub packages already do.

@jiffyclub: would you be interested in a PR for this?

@jradavenport: would it be ok with you (given licensing) to take cubehelix.cmap and re-mix it into palettable?

(This is in the same spirit as #8 but I wanted to make a new issue for this specific proposal)

matplotlib issue in osx

When trying to use the .mpl_colormap functionality even with matplotlib installed, I was getting

File "/Users/brianjac/.virtualenvs/bird/lib/python2.7/site-packages/palettable/palette.py", line 99, in get_mpl_colormap
    raise RuntimeError('matplotlib not available.')

I'm using a python virtual environment. Turns out I needed to do this step:
https://stackoverflow.com/a/35107136/4863986

This took some sleuthing, maybe worth mentioning in the documentation, as matplotlib is needed to use certain functions like .mpl_colormap

I would also love to see some more cookbook examples on how to use this library for generic lists of interpolated colors not feeding into matlab plots.

Otherwise, great library, thanks!

Other colormaps

Would there be intterest in including support for other colormap families?

Other families I had in mind were Matlab's parula colormap (see here), d3 (see here), ggplot2 (see here), tableau (see here), and some of the ones shown here.

Package rename?

Do you think it's too late to rename the package to something more generic? colormap is taken, but colormaps seems to be available still.

support plotly?

Is there any interest in support plotly?

The latest plotly version is v5.4, in an earlier documentation in v3 that doesn't seem to exist now, it demonstrates how to convert from matplotlib color to plotly's.

However hackingmaterials/matminer#232 (comment) mentioned

converting matplotlib color maps into Plotly-capable format doesn't work outside of the few examples Plotly provides

without much details or even mention if it is the method outlined in the page above. So may be it is not so easy to support it.

make full LUT data available via public API?

Hi and thanks for the library,

Apologies if I missed this, but I'm wondering if there is a public API to access, for example, the full set of colors in the matplotlib viridis or magma data (i.e. the values in palettable.matplotlib.matplotlib._NAMES_TO_DATA

It appears that one would have to use palettable.matplotlib.Viridis_20.mpl_colormap to get a mpl colormap using the truncated 20-color data, then re-interpolate... is that correct?

License file in pypi archive

The pypi source archive isn't including the license.txt file. Would it be possible to add it? It is very helpful when packaging this for Linux distributions. Thank you.

feature request: high-level unique name for accessing palettes

Sometimes it can be hard knowing how to traverse palettable to get the palette you need. Unless I'm missing something, there does not seem to be a high level way of accessing palettes without prior knowledge about the structure of palettable. It'd be really handy to have a high-level get method to access a palette without advanced knowledge about how it's nested within palettable.

For instance, some palettes can be accessed like:

palettable.<class>.<module>.<palette_name>

E.g., palettable.colorbrewer.diverging.PRGn_11. This requires more information than just the palette name. Programmatically, it'd be accessed like the following if a user needed a specific palette:

>>> r = dict(cls='colorbrewer', module='diverging', palette='PRGn', n_colors='11')
>>> getattr(getattr(getattr(palettable, r['cls']), r['module']), r['palette'] + '_' + r['n_colors']).hex_colors
['#40004B', '#762A83', '#9970AB', '#C2A5CF', '#E7D4E8', '#F7F7F7', '#D9F0D3', '#A6DBA0', '#5AAE61', '#1B7837', '#00441B']

Others palettes are accessed like:

palettable.<class>.<palette_name>

For example, palettable.matplotlib.Inferno_13, which is much more easily accessible but still requires knowledge that the palette comes from matplotlib, which may or may not be relevant to the user.

It'd be really nice to have a high-level get method (or something like that) to retrieve palettes by a unique name that would return the palette object that you want to retrieve information from.

I can imagine something of the form:

>>> mpl_inf_13 = palettable.get('inferno', 13, reversed=True)
>>> mpl_inf_13.hex_colors
['#40004B', '#762A83', '#9970AB', '#C2A5CF', '#E7D4E8', '#F7F7F7', '#D9F0D3', '#A6DBA0', '#5AAE61', '#1B7837', '#00441B']

The user is only defining what they want, but it adds the additional constraint that no two palettes across the package can have the same name.

docs: colors are not "RGB tuples"

colors : The defined colors in the palette as a list of RGB tuples in the range 0-255.

They are lists of lists of RGB values, not actual tuples (immutable sequences). I see why it says that, but tuple is an actual Python type, so perhaps it shoudn't?

Add simple `make_palette` interface

Right now, there's a barrier for me to use palettable directly because I have to remember to include the number of colors I want for each colormap when I do the import, and I don't always know where I want to look for the palette I want. Could there be a palettable.make_palette("palettename", n_colors=8) - type interface?

The official release of palettable is broken

Immediate Problem

palettable requires setuptools as a runtime dependency but it is not listed in the official release. This was fixed in b20cdca, was not released.

Up to now, this issue has effectively been masked by at-least one of:

  1. Virtual environments tend to pre-install setuptools when they are created. This is not a standard requirement.
  2. Packages that depend on palettable may also have included setuptools as a runtime dependency.

The "new" packaging & installation standards (e.g PEP 518, PEP 621) have now been around long enough that installation tools & other packages have started to strictly adhere to them. That means fewer chances of setuptools being installed in the user environment.

Larger Problem

palettable vendors ez_setup as a way to sidestep setuptools during installation, yet setuptools is a runtime dependency! Juggling build/installation time and runtime dependencies is best done in a standards compliant way.
ez_setup predates these standards and may contribute to or mask other installation problems.

Solution
Possible immediate solution: Make a release.
Better immediate solution: Consider PR #46, remove setuptools as a runtime dependency and make a release.
Final solution: Move to a standard installation process.

Documentation page scroll is broken in Safari

The documentation page looks ok when initially loaded, but after scrolling down the text becomes misaligned.

(Click on images to see a larger version)

I'm using Safari Version 13.1 (15609.1.20.111.8) (most recent) on macOS Catalina version 10.15.4. I've tested it in Chrome and it works perfectly well.

Wheel packaging format for pypi.org

Would it be possible to get a .whl universal package on Pypi ?

If I'm right, it's just a matter of adding a setup.cfg file at root level with

[wheel]
universal = 1

and then doing this to upload to pypi

python setup.py sdist bdist_wheel upload -r pypi

Declaring brewer2mpl as an install_requires installs it as an egg, breaking it.

After declaring brewer2mpl as a dependency in a setuptools setup.py, brewer2mpl is installed as an egg (zip), so importing it breaks as it cannot open _DATAFILE.

$ python -c 'import brewer2mpl'   
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/path/to/virtualenv/lib/python3.4/site-packages/brewer2mpl-1.4-py3.4.egg/brewer2mpl/__init__.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/path/to/virtualenv/lib/python3.4/site-packages/brewer2mpl-1.4-py3.4.egg/brewer2mpl/brewer2mpl.py", line 21, in <module>
NotADirectoryError: [Errno 20] Not a directory: '/path/to/virtualenv/lib/python3.4/site-packages/brewer2mpl-1.4-py3.4.egg/brewer2mpl/data/colorbrewer_all_schemes.json'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.