def __init__(self, type='seq', palette=1, values=None, **kwargs): """ Create colormap that will be used by the palette """ if type.lower() in ('qual', 'qualitative'): warn("Using a discrete color palette in a continuous scale." "Consider using type = 'seq' or type = 'div' instead") # Grab 6 colors from brewer and create a gradient palette colors = brewer_pal(type, palette)(6) scale_color_gradientn.__init__(self, colors, values, **kwargs)
def __init__(self, type='seq', palette=1, values=None, **kwargs): """ Create colormap that will be used by the palette """ if type.lower() in ('qual', 'qualitative'): warn("Using a discrete color palette in a continuous scale." "Consider using type = 'seq' or type = 'div' instead") # Grab 6 colors from brewer and create a gradient palette colors = brewer_pal(type, palette)(6) scale_color_gradientn.__init__(self, colors, values, **kwargs)
def __init__(self, type='seq', palette=1, values=None, **kwargs): """ Create colormap that will be used by the palette """ if type.lower() in ('qual', 'qualitative'): warn( "Using a discrete color palette in a continuous scale." "Consider using type = 'seq' or type = 'div' instead", PlotnineWarning) # Grab 7 colors from brewer and create a gradient palette # An odd number matches the midpoint of the palette to that # of the data colors = brewer_pal(type, palette)(7) scale_color_gradientn.__init__(self, colors, values, **kwargs)
def test_brewer_pal(): result = brewer_pal()(5) assert all(s[0] == '#' and len(s) == 7 for s in result) result = brewer_pal('qual', 2)(5) assert all(s[0] == '#' and len(s) == 7 for s in result) result = brewer_pal('div', 2)(5) assert all(s[0] == '#' and len(s) == 7 for s in result) with pytest.raises(ValueError): brewer_pal('div', 200)(5) result = brewer_pal('seq', 'Greens')(5) assert all(s[0] == '#' and len(s) == 7 for s in result) with pytest.warns(UserWarning): brewer_pal()(100) result = brewer_pal('seq', 'Blues')(2) assert all(s[0] == '#' and len(s) == 7 for s in result)
def test_brewer_pal(): result = brewer_pal()(5) assert all(s[0] == '#' and len(s) == 7 for s in result) result = brewer_pal('qual', 2)(5) assert all(s[0] == '#' and len(s) == 7 for s in result) result = brewer_pal('div', 2)(5) assert all(s[0] == '#' and len(s) == 7 for s in result) with pytest.raises(ValueError): brewer_pal('div', 200)(5) result = brewer_pal('seq', 'Greens')(5) assert all(s[0] == '#' and len(s) == 7 for s in result) with pytest.warns(UserWarning): brewer_pal()(100) result = brewer_pal('seq', 'Blues')(2) assert all(s[0] == '#' and len(s) == 7 for s in result)
def __init__(self, type='seq', palette=1, **kwargs): self.palette = brewer_pal(type, palette) scale_discrete.__init__(self, **kwargs)
def __init__(self, type="seq", palette=1, direction=-1, **kwargs): self.palette = brewer_pal(type, palette, direction) scale_discrete.__init__(self, **kwargs)
def __init__(self, type='seq', palette=1, **kwargs): self.palette = brewer_pal(type, palette) scale_discrete.__init__(self, **kwargs)
#%% # inversed copy PrecDaytiDF['daytime2']=pd.Categorical(PrecDaytiDF.daytime, categories=RightOrder[::-1], ordered=True) #%% # ad-hoc set of colors adHoc=['white','white','black','black'] # manual colors according to Brewer. from mizani.palettes import brewer_pal Greys4=brewer_pal(palette='Greys')(4)[::-1] #%% base3= ggplot(PrecDaytiDF, aes(x='precint', y='counts', fill='daytime2')) + theme_classic() # order of horizontal barStacked2c = base3 +scale_x_discrete(limits=newPrecintAxis2) # manual Brewer palette barStacked2c += scale_fill_manual(values=Greys4) # usual barStacked2c += geom_bar(stat="identity", color='grey') # annotating with color (default color will be assigned) barStacked2c += geom_text(aes(label='counts', color='daytime2'), size = 8,