Changing Yellowbrick visiualization colors - python-3.x

In Yellowbrick visiualization library, the default color for the classification report is red: from lighter to darker tones. Is there a way to change this color and use green, blue, etc.?

when defining the visualizer, you can set a color sequence(cmap).
viz = ClassificationReport(model, cmap='PuRd')
viz.score(X_test, y_test)
You can find the different color sequences at
http://www.scikit-yb.org/en/latest/api/palettes.html#color-sequences

Related

How to use hist_kws in seaborn displot

I want to plot histogram and kde line in the same plot with different color. I want to set green color for the histogram and blue color for the kde line. I managed to figure out using line_kws to change the kde line color but hist_kws is not working on the displot. I have tried using histplot but I am unable to put different color for the hist and the line.
You can use line_kws={'color': ...} to change the color of the kde line. And directly facecolor=... to change the color of the histogram.
The following code has been tested with seaborn 0.11.1 and displot with the default kind (kind='hist') and no hue:
sns.displot(..., facecolor=...) changes the color of the histogram faces
sns.displot(..., edgecolor=...) changes the color of the histogram edges
sns.displot(..., color=...) changes the color of the kde line (when kde=True)
sns.displot(..., line_kws={'lw':...}) changes the parameters of the kdeline, except the color
Here is an example:
import seaborn as sns
penguins = sns.load_dataset('penguins')
sns.displot(data=penguins, x="flipper_length_mm", kde=True, col="species", color='red',
line_kws={'lw': 3}, facecolor='lime', edgecolor='black')
Seaborn's forte is the hue parameter, placing multiple distributions together, for which it is very handy that corresponding kde and histogram get the same color. When using hue, the above coloring gets overridden.
hist_kws is an optional argument in distplot which takes only values in a dictionary. You can use this to set linewidth, edgecolor etc.
Example for your ref

Color is getting darker when using alpha channel / opacity

I draw to a texture with a fragment shader in opengl.
I set my color to 100% red and 50% opacity, but when i then read this color i discover that it is no longer 100% red.
The same can be noticed with gimp.
I choose 100% red color but draw it with 50% opacity, when i then use the color picker tool, it tells me the red color is only 80%.
Is there a way to preserve the color value in opengl es 2.0?
The color is modified by the Bending function and operation. You have to disable blending.
There is no opacity, there is just an alpha channel. The alpha channel and the blend function define how a source color is mixed (blended) with the color in the target buffer. Hence if blending is enabled, then the final color is equal to the source color. If blending is disabled, the the color and the alpha channel are copied to the target without manipulation.

GIMP - Alpha to Color

I have created a simple square using GIMP which color is a shade of blue (#07192c). I lowered the opacity on this square a bit, and realized I like the shade of blue which was now created from lowering the opacity.
My question is, does GIMP have a function which allows you to select (like the eyedropper) the color of a transparent layer? I've searched but can only find 'color to alpha' which is not what I'm looking for.
You can activate the Sample merged option of the Color Picker tool. This will pick the color as it is shown in the image composition.
This setting is available in the tool options for the color picker:
Layer -> Transparency -> Remove Alpha Channel
Colours -> Map -> Colour Exchange...

color blending with GDI+

I am refering to a older question saying color blending with GDI+
Using GDI+ with Windows Forms, I want to be able to draw with a pen and blend color based on the destination pixel color.
For example, if I draw a line and it passes over black pixels, I want it to be a lighter color (like white for example) so that it's visible. When that same line passes over white pixels, it should be a darker color (black for example) so that it's still clearly visible.
the answers says to use a color matrix for transformation
so i started implementing it..
My image is present in raw data format in rgb48
Gdiplus::Bitmap image(input.width,input.height,input.width*6,PixelFormat48bppRGB,(unsigned char*)rgb48);
Gdiplus::Image *images= image.GetThumbnailImage(input.width,input.height);
Gdiplus::TextureBrush brush(images);
Gdiplus::Pen pen(&brush);
Gdiplus::ColorMatrix matrix={
-1.0f,0.0f,0.0f,0.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,0.0f,
0.0f,0.0f,-1.0f,0.0f,0.0f,
0.0f,0.0f,0.0f,1.0f,0.0f,
1.0f,1.0f,1.0f,0.0f,1.0f,
};
Gdiplus::Graphics gfx(&image1);
Gdiplus::ImageAttributes imageAttr;
imageAttr.SetColorMatrix(&matrix);
gfx.DrawImage(images,Gdiplus::Rect(0,0,input.width,input.height),0,0,1024,1024,Gdiplus::UnitPixel,&imageAttr);
I am not getting what i expect..Can some one help me in finding the mistake i m doing.
You can use the alpha component of a color to specify transparency, so that colors can be combined. However, if you want the combination to be something other than the alpha blend, you must draw the pixels yourself. You could first draw into a transparent bitmap, then render that onto the destination pixel by pixel.

Color Space Inversion for contrasting grid

I have a randomly colored background that is split into solid colored rectangles. I want to draw a grid over the rectangles (this is not the problem). The issue is because of the random colors I cannot hard-code the grid color because it may not show up.
Another way to think about this is plotting a grid on a plot of a surface f(x,y). If the grid color happens to be the same color of the function (however it is defined) then it won't be visible.
I would like to take the background color and compute a new color (either grayscale or similar to the background color) that is contrasted with the color so it can easily be seen (but not distracting such as pure white on pure black).
I've tried using the luminance and weighted luminance but it doesn't work well for all colors. I've also tried gamma correcting the colors but it also does not work well.
I would also like the grid color to be as uniform as possible (I could possibly compute the adjacent grid colors to blend in). It is not that important but would be nice to have some uniformity.
The code I'm working with is based around
//byte I = (byte)(0.2*R + 0.7*G + 0.1*B);
//byte I = (byte)(R + G + B)/3.0);
byte I = (byte)(Math.Max(Bar.Background.R, Math.Max(Bar.Background.G, Bar.Background.B)));
if (I < 120)
I = (byte)(I + 30);
else
I = (byte)(I - 30);
//I = (byte)(Math.Pow(I/255.0, 1/2.0)*255);
I've also tried gamma correcting the rgb's first.
Anyone have any ideas?
The colors that offer the most contrast are colors that are fully saturated. This offers you a way to find color that may work(but not necessarily for many reasons). Essentially you pick the color the furthest away along the line connecting color and the fully saturated color.

Resources