Can I create sns color palettes? - pandas

I'm using these seaborn palettes
sns.color_palette('light:b')
I get from light to blue like this.
If I go 'dark:b', it goes from dark to blue.
Can I go something like this 'dark:b:light, from dark to blue, from blue to light, to custom every color I use (red, green, blue, purple and other)?

Seaborn contains a lot of function to create color palettes and color maps. An introuction can be found at the palette tutorial and at sns.color_palette()'s documentation.
A way to blend between multiple colors is sns.color_palette('blend:red,green,blue,purple', as_cmap=True).
So, the answer to your question is "yes, you can create color palettes". E.g. sns.color_palette('blend:0.1,blue,0.9', as_cmap=True) would go from dark over blue to light. (Note that a string with a number between 0 and 1 represents a gray value when interpreted as a color in matplotlib.)

Related

R Change ggplot scatterplot colors

I'm an R newbie and have searched for the answer to this to no avail.
I have a simple ggplot scatterplot that I set the color to "cluster" of which there are 3. The plot comes out great and is colored in 3 shades of blue. I want the colors to be dark blue, orange, and green. How do I do this? I've been toying with scale_color_manual and cannot get anything to work.
Cheers
Jeff
Possibly cluster is a numeric variable, then ggplot uses scale_color_continuous. Try converting "cluster" to character or to factor and then try scale_color_manual
What does your data/code look like? You scale_color_manual should look like this:
scale_color_manual(values=c("blue", "orange", "green")

Why matplotlib.pyplot.imshow does not show colors correctly?

Why colors are not accurate when using numpy arrays as inputs for imshow()?, I was expecting a pure blue, but I see in a color picker there is a value of 55 in red (scale 0..255), why is this?

SSRS Graded colour scale

Can SSRS make a graded colour scale (like Excel). I am attatching an image to explain what I mean.
Regards.
Yes, but it's not very easy. You can use an expression to dynamically set the fill color of a cell. The colors can be specified with their hex representation like "#AC9494". You will have to come up with a formula to define which colors the scale goes through.
Red is "#FF0000" and green is "#00FF00". So your formula would have to scale the amount of green and red (and maybe some blue) you want, convert that to hex, and then concatenate them into this format. If you search for terms like "smooth color gradient" you will get some helpful examples to point you in the right direction.

Lesscss: Why spin(#000,180) is returning #000?

I need to know how to get the inverse color by lesscss.
Example: I have #000, i need #FFF.
And i need the detail explanation of spin(). And necessary links where i can see a color wheel where i can understand how spin() works.
Thanks.
Why it is not working as you expect
The spin() function only deals with hue (color), not value (grey scale changes are a value change). Take a look at Figures 9 and 10 on this page from North Carolina State University's site. Those figures help show the difference. The spin() function is rotating only in the two dimensional space of the hue circle of color, not along the axis of the third dimensional space dealing with saturation; i.e. the gray scale itself, which is what differentiates white from black, both of which have no color saturation).
This is why on the LESS site we read of spin() (emphasis added):
Note that colors are passed through an RGB conversion, which doesn't
retain hue value for greys (because hue has no meaning when there is
no saturation)
And
Colors are always returned as RGB values, so applying spin to a grey
value will do nothing.
Getting what you want (Color Inversion)
See #seven-phases-max's answer.
The spin function changes the Hue property of a colour. Shades of grey (incl. white and black) are achromatic colours (i.e. they have the same "undefined" hue value).
To simply invert a colour use either difference function:
difference(white, #colour)
or the simple colour arithmetic:
(#fff - #colour)

set color limits in python colormap

I need to display data from a 2D matrix in a gray colormap, but I need to define it in such a gray scale that white and black are not the colors for the min and max values of the matrix, in order to not saturate the image. What I need is a gray scale colormap with gray levels between 20% and 70%, with at least 20% difference between the levels of gray. Any suggestions?
I'm using the imshow task form matplotlib.
Thanks a lot!
Did you solve your problem?
I guess this is what you want, try this:
all code in pylab mode:
a = np.arange(100).reshape(10,10)
#here is the image with white and black end
imshow(a,cmap=mat.cm.binary)
colorbar()
#we extract only the 0.2-->0.7 part of original colormap and make a new one
#so that the white and black end are removed
rgba_array = mat.cm.binary(np.linspace(0,1,num=10,endpoint=True))
extract_rgba_array_255 = rgba_array[2:8,0:3]
imshow(a,cmap=mat.colors.ListedColormap(extract_rgba_array_255))
colorbar()
You could do this either by creating a custom color map with colors your prefer, or by using the vmin, vmax keywords in imshow to force a larger range on the colorbar than you want to use in your plot.