Skip to content

Commit

Permalink
Merge pull request #1627 from CartoDB/jarroyo/ch72852/fix-viz-palettes
Browse files Browse the repository at this point in the history
Fix viz palettes
  • Loading branch information
Jesus89 committed Apr 30, 2020
2 parents fdcf720 + 03c3cb7 commit e6d0217
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 73 deletions.
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'

0 comments on commit e6d0217

Please sign in to comment.