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

Fix viz palettes #1627

Merged
merged 2 commits into from
Apr 30, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cartoframes/viz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from .themes import Themes as themes
from .basemaps import Basemaps as basemaps
from .defaults import COLOR_PALETTES as palettes
from .palettes import Palettes as palettes

from .styles import animation_style
from .styles import basic_style
Expand Down
72 changes: 0 additions & 72 deletions cartoframes/viz/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,75 +15,3 @@
'strokeColor': 'opacity(#2c2c2c,ramp(linear(zoom(),2,18),[0.2,0.6]))'
}
}

COLOR_PALETTES = [
'BURG',
'BURGYL',
'REDOR',
'ORYEL',
'PEACH',
'PINKYL',
'MINT',
'BLUGRN',
'DARKMINT',
'EMRLD',
'AG_GRNYL',
'BLUYL',
'TEAL',
'TEALGRN',
'PURP',
'PURPOR',
'SUNSET',
'MAGENTA',
'SUNSETDARK',
'AG_SUNSET',
'BRWNYL',
'ARMYROSE',
'FALL',
'GEYSER',
'TEMPS',
'TEALROSE',
'TROPIC',
'EARTH',
'ANTIQUE',
'BOLD',
'PASTEL',
'PRISM',
'SAFE',
'VIVID'
'CB_YLGN',
'CB_YLGNBU',
'CB_GNBU',
'CB_BUGN',
'CB_PUBUGN',
'CB_PUBU',
'CB_BUPU',
'CB_RDPU',
'CB_PURD',
'CB_ORRD',
'CB_YLORRD',
'CB_YLORBR',
'CB_PURPLES',
'CB_BLUES',
'CB_GREENS',
'CB_ORANGES',
'CB_REDS',
'CB_GREYS',
'CB_PUOR',
'CB_BRBG',
'CB_PRGN',
'CB_PIYG',
'CB_RDBU',
'CB_RDGY',
'CB_RDYLBU',
'CB_SPECTRAL',
'CB_RDYLGN',
'CB_ACCENT',
'CB_DARK2',
'CB_PAIRED',
'CB_PASTEL1',
'CB_PASTEL2',
'CB_SET1',
'CB_SET2',
'CB_SET3'
]
88 changes: 88 additions & 0 deletions cartoframes/viz/palettes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
class Palettes: # pylint: disable=too-few-public-methods
"""Color palettes applied to Map visualizations in the style helper methods.
By default, each color helper method has its own default palette.
More information at https://carto.com/carto-colors/

Example:
Create color bins style with the burg palette

>>> color_bins_style('column name', palette=palettes.burg)

"""
pass


PALETTES = [
'BURG',
'BURGYL',
'REDOR',
'ORYEL',
'PEACH',
'PINKYL',
'MINT',
'BLUGRN',
'DARKMINT',
'EMRLD',
'AG_GRNYL',
'BLUYL',
'TEAL',
'TEALGRN',
'PURP',
'PURPOR',
'SUNSET',
'MAGENTA',
'SUNSETDARK',
'AG_SUNSET',
'BRWNYL',
'ARMYROSE',
'FALL',
'GEYSER',
'TEMPS',
'TEALROSE',
'TROPIC',
'EARTH',
'ANTIQUE',
'BOLD',
'PASTEL',
'PRISM',
'SAFE',
'VIVID'
'CB_YLGN',
'CB_YLGNBU',
'CB_GNBU',
'CB_BUGN',
'CB_PUBUGN',
'CB_PUBU',
'CB_BUPU',
'CB_RDPU',
'CB_PURD',
'CB_ORRD',
'CB_YLORRD',
'CB_YLORBR',
'CB_PURPLES',
'CB_BLUES',
'CB_GREENS',
'CB_ORANGES',
'CB_REDS',
'CB_GREYS',
'CB_PUOR',
'CB_BRBG',
'CB_PRGN',
'CB_PIYG',
'CB_RDBU',
'CB_RDGY',
'CB_RDYLBU',
'CB_SPECTRAL',
'CB_RDYLGN',
'CB_ACCENT',
'CB_DARK2',
'CB_PAIRED',
'CB_PASTEL1',
'CB_PASTEL2',
'CB_SET1',
'CB_SET2',
'CB_SET3'
]

for palette in PALETTES:
setattr(Palettes, palette.lower(), palette)
13 changes: 13 additions & 0 deletions tests/unit/viz/test_palettes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from cartoframes.viz import palettes


class TestPalettes(object):
def test_is_defined(self):
"palettes"
assert palettes is not None

def test_has_defined_palettes(self):
"palettes content"
assert palettes.burg == 'BURG'
assert palettes.burgyl == 'BURGYL'
assert palettes.cb_set3 == 'CB_SET3'