Beispiel #1
0
def features_visualization(features):
    '''
    features - a dictionary of track features
    prints a bar chart of selected features (on the same scale of 0-1)
    '''
    feature_dict = copy.deepcopy(features)
    # exclude some features
    for feature in [
            'time_signature', 'mode', 'loudness', 'key', 'tempo',
            'duration_ms', 'analysis_url', 'id', 'track_href', 'type', 'uri'
    ]:
        del feature_dict[feature]

    # customize chart style
    custom_style = Style(background='rgba(253, 247, 246, 0.4)',
                         plot_background='rgba(249, 228, 225, 1)',
                         foreground='rgba(0, 0, 0, 0.9)',
                         foreground_strong='rgba(0, 0, 0, 0.9)',
                         foreground_subtle='rgba(0, 0, 0, 0.5)',
                         opacity='.6',
                         opacity_hover='.9',
                         colors=('#d94e4c', '#e5884f', '#39929a',
                                 lighten('#d94e4c', 10), darken('#39929a', 15),
                                 lighten('#e5884f',
                                         17), darken('#d94e4c',
                                                     10), '#234547'))

    # create chart
    chart = pygal.HorizontalBar(style=custom_style)
    chart.title = 'Track Features'
    for feature, value in feature_dict.items():
        chart.add(feature, value)
    chart.render()

    return chart.render_data_uri()
Beispiel #2
0
class TurquoiseStyle(Style):
    """A turquoise style"""

    background = darken('#1b8088', 15)
    plot_background = darken('#1b8088', 17)
    foreground = 'rgba(255, 255, 255, 0.9)'
    foreground_strong = 'rgba(255, 255, 255, 0.9)'
    foreground_subtle = 'rgba(255, 255 , 255, 0.5)'
    opacity = '.5'
    opacity_hover = '.9'
    transition = '250ms ease-in'
    colors = ('#93d2d9', '#ef940f', '#8C6243', '#fff', darken('#93d2d9', 20),
              lighten('#ef940f', 15), lighten('#8c6243', 15), '#1b8088')
Beispiel #3
0
class DarkGreenBlueStyle(Style):
    """A dark green and blue style"""

    background = '#000'
    plot_background = lighten('#000', 8)
    foreground = 'rgba(255, 255, 255, 0.9)'
    foreground_strong = 'rgba(255, 255, 255, 0.9)'
    foreground_subtle = 'rgba(255, 255, 255, 0.6)'
    opacity = '.55'
    opacity_hover = '.9'
    transition = '250ms ease-in'
    colors = (lighten('#34B8F7', 15), '#7dcf30', '#247fab',
              darken('#7dcf30', 10), lighten('#247fab', 10),
              lighten('#7dcf30', 10), darken('#247fab', 10), '#fff')
Beispiel #4
0
class RedBlueStyle(Style):
    """A red and blue theme"""

    background = lighten('#e6e7e9', 7)
    plot_background = lighten('#e6e7e9', 10)
    foreground = 'rgba(0, 0, 0, 0.9)'
    foreground_strong = 'rgba(0, 0, 0, 0.9)'
    foreground_subtle = 'rgba(0, 0, 0, 0.5)'
    opacity = '.6'
    opacity_hover = '.9'
    colors = ('#d94e4c', '#e5884f', '#39929a', lighten('#d94e4c', 10),
              darken('#39929a', 15), lighten('#e5884f',
                                             17), darken('#d94e4c',
                                                         10), '#234547')
Beispiel #5
0
class BlueStyle(Style):
    """A blue style"""

    background = darken('#f8f8f8', 3)
    plot_background = '#f8f8f8'
    foreground = 'rgba(0, 0, 0, 0.9)'
    foreground_strong = 'rgba(0, 0, 0, 0.9)'
    foreground_subtle = 'rgba(0, 0, 0, 0.6)'
    opacity = '.5'
    opacity_hover = '.9'
    transition = '250ms ease-in'
    colors = ('#00b2f0', '#43d9be', '#0662ab', darken('#00b2f0', 20),
              lighten('#43d9be', 20), lighten('#7dcf30', 10),
              darken('#0662ab', 15), '#ffd541', '#7dcf30',
              lighten('#00b2f0', 15), darken('#ffd541', 20))
Beispiel #6
0
class LightGreenStyle(Style):
    """A light green style"""

    background = lighten('#f3f3f3', 3)
    plot_background = '#fff'
    foreground = '#333333'
    foreground_strong = '#666'
    foreground_subtle = '#222222'
    opacity = '.5'
    opacity_hover = '.9'
    transition = '250ms ease-in'
    colors = ('#7dcf30', '#247fab', lighten('#7dcf30', 10), '#ccc',
              darken('#7dcf30',
                     15), '#ddd', lighten('#247fab',
                                          10), darken('#247fab', 15))
Beispiel #7
0
class DarkColorizedStyle(Style):
    """A dark colorized style"""

    background = darken('#3a2d3f', 5)
    plot_background = lighten('#3a2d3f', 2)
    foreground = 'rgba(255, 255, 255, 0.9)'
    foreground_strong = 'rgba(255, 255, 255, 0.9)'
    foreground_subtle = 'rgba(255, 255 , 255, 0.5)'
    opacity = '.2'
    opacity_hover = '.7'
    transition = '250ms ease-in'
    colors = ('#c900fe', '#01b8fe', '#59f500', '#ff00e4', '#f9fa00',
              darken('#c900fe', 20), darken('#01b8fe', 15),
              darken('#59f500', 20), darken('#ff00e4',
                                            15), lighten('#f9fa00', 20))
Beispiel #8
0
class LightColorizedStyle(Style):
    """A light colorized style"""

    background = '#f8f8f8'
    plot_background = lighten('#f8f8f8', 3)
    foreground = '#333'
    foreground_strong = '#666'
    foreground_subtle = 'rgba(0, 0 , 0, 0.5)'
    opacity = '.5'
    opacity_hover = '.9'
    transition = '250ms ease-in'
    colors = ('#fe9592', '#534f4c', '#3ac2c0', '#a2a7a1',
              darken('#fe9592', 15), lighten('#534f4c',
                                             15), lighten('#3ac2c0', 15),
              lighten('#a2a7a1', 15), lighten('#fe9592',
                                              15), darken('#3ac2c0', 10))
Beispiel #9
0
def test_lighten():
    assert lighten('#800', 20) == '#ee0000'
    assert lighten('#800', 0) == '#880000'
    assert lighten('#ffffff', 10) == '#ffffff'
    assert lighten('#000000', 10) == '#1a1a1a'
    assert lighten('#f3148a', 25) == '#f98dc6'
    assert lighten('#121212', 1) == '#151515'
    assert lighten('#999999', 100) == '#ffffff'
    assert lighten('#1479ac', 8) == '#1893d1'
Beispiel #10
0
def test_lighten():
    assert lighten('#800', 20) == '#e00'
    assert lighten('#800', 0) == '#800'
    assert lighten('#ffffff', 10) == '#ffffff'
    assert lighten('#000000', 10) == '#1a1a1a'
    assert lighten('#f3148a', 25) == '#f98dc6'
    assert lighten('#121212', 1) == '#151515'
    assert lighten('#999999', 100) == '#ffffff'
    assert lighten('#1479ac', 8) == '#1893d1'
Beispiel #11
0
def test_lighten():
    """Test lighten color function"""
    assert lighten('#800', 20) == '#e00'
    assert lighten('#800', 0) == '#800'
    assert lighten('#ffffff', 10) == '#ffffff'
    assert lighten('#000000', 10) == '#1a1a1a'
    assert lighten('#f3148a', 25) == '#f98dc6'
    assert lighten('#121212', 1) == '#151515'
    assert lighten('#999999', 100) == '#ffffff'
    assert lighten('#1479ac', 8) == '#1893d1'
Beispiel #12
0
    def __init__(self):
        mystyle = Style(
            #background=darken('#f8f8f8', 3),
            background='white',
            plot_background='white',
            foreground='rgba(0, 0, 0, 0.9)',
            foreground_light='rgba(0, 0, 0, 0.9)',
            foreground_dark='rgba(0, 0, 0, 0.6)',
            opacity='.5',
            opacity_hover='.9',
            transition='250ms ease-in',
            colors=('#00b2f0', '#43d9be', '#0662ab', darken('#00b2f0', 20),
                    lighten('#43d9be', 20), lighten('#7dcf30', 10),
                    darken('#0662ab', 15), '#ffd541', '#7dcf30',
                    lighten('#00b2f0', 15), darken('#ffd541', 20)))

        self.tmpDir = tempfile.mkdtemp()
        self.config = pygal.Config(style=mystyle,
                                   legend_font_size=10,
                                   width=500,
                                   height=250)
Beispiel #13
0
	def __init__(self):
            mystyle = Style(
               #background=darken('#f8f8f8', 3),
               background='white',
               plot_background='white',
               foreground='rgba(0, 0, 0, 0.9)',
               foreground_light='rgba(0, 0, 0, 0.9)',
               foreground_dark='rgba(0, 0, 0, 0.6)',
               opacity='.5',
               opacity_hover='.9',
               transition='250ms ease-in',
               colors=('#00b2f0', '#43d9be', '#0662ab', 
                        darken('#00b2f0', 20),lighten('#43d9be', 20), 
                        lighten('#7dcf30', 10), darken('#0662ab', 15),
                        '#ffd541', '#7dcf30', lighten('#00b2f0', 15), darken('#ffd541', 20))
               )
            
            self.tmpDir = tempfile.mkdtemp()
            self.config = pygal.Config(style=mystyle,
                                      legend_font_size=10,
                                      width=500,height=250) 
Beispiel #14
0
class DarkGreenStyle(Style):
    """A dark green style"""

    background = darken('#251e01', 3)
    plot_background = darken('#251e01', 1)
    foreground = 'rgba(255, 255, 255, 0.9)'
    foreground_strong = 'rgba(255, 255, 255, 0.9)'
    foreground_subtle = 'rgba(255, 255, 255, 0.6)'
    opacity = '.6'
    opacity_hover = '.9'
    transition = '250ms ease-in'
    colors = ('#adde09', '#6e8c06', '#4a5e04', '#fcd202', '#C1E34D',
              lighten('#fcd202', 25))
Beispiel #15
0

LightSolarizedStyle = Style(
    background='#fdf6e3',
    plot_background='#eee8d5',
    foreground='#657b83',
    foreground_light='#073642',
    foreground_dark='#073642',
    opacity='.6',
    opacity_hover='.9',
    transition='500ms ease-in',
    colors=solarized_colors)


RedBlueStyle = Style(
    background=lighten('#e6e7e9', 7),
    plot_background=lighten('#e6e7e9', 10),
    foreground='rgba(0, 0, 0, 0.9)',
    foreground_light='rgba(0, 0, 0, 0.9)',
    foreground_dark='rgba(0, 0, 0, 0.5)',
    opacity='.6',
    opacity_hover='.9',
    colors=(
        '#d94e4c', '#e5884f', '#39929a',
        lighten('#d94e4c', 10),  darken('#39929a', 15), lighten('#e5884f', 17),
        darken('#d94e4c', 10), '#234547'))


LightColorizedStyle = Style(
    background='#f8f8f8',
    plot_background=lighten('#f8f8f8', 3),
Beispiel #16
0

LightSolarizedStyle = Style(
    background='#fdf6e3',
    plot_background='#eee8d5',
    foreground='#657b83',
    foreground_light='#073642',
    foreground_dark='#073642',
    opacity='.6',
    opacity_hover='.9',
    transition='500ms ease-in',
    colors=solarized_colors)


RedBlueStyle = Style(
    background=lighten('#e6e7e9', 7),
    plot_background=lighten('#e6e7e9', 10),
    foreground='rgba(0, 0, 0, 0.9)',
    foreground_light='rgba(0, 0, 0, 0.9)',
    foreground_dark='rgba(0, 0, 0, 0.5)',
    opacity='.6',
    opacity_hover='.9',
    colors=(
        '#d94e4c', '#e5884f', '#39929a',
        lighten('#d94e4c', 10),  darken('#39929a', 15), lighten('#e5884f', 17),
        darken('#d94e4c', 10), '#234547'))


LightColorizedStyle = Style(
    background='#f8f8f8',
    plot_background=lighten('#f8f8f8', 3),