wordcloud2 drops long words, which gets the colors mismatched - colors

so i have a dynamic list of text that i want to visualize in a wordcloud. sometimes some of the words are too long and they get dropped from the display. i can scale down the size of everything, but it's not always clear what scale i should get down to in order to prevent things from being dropped. i'd rather not fiddle with this and just accept some things are dropped. also, everything is in a shiny app and i have a slider to control scale if really needed. the problem though is i want my text colored by properties of the words in my dataset. in this example below you can see how each "word" has a color associated with it...
wc <- data.frame(
word = c("too big to fit this one is","red","green","blue"),
freq = c(2,1,2,3),
col = c("black","red","green","blue"),
stringsAsFactors = FALSE
)
>wc
word freq col
1 too big to fit this one is 2 black
2 red 1 red
3 green 2 green
4 blue 3 blue
wordcloud2(wc, color = wc$col)
this then draws the wordcloud but the first element is dropped and the colors don't drop too ("red" is colored black, "green" is colored red, and "blue" is colored green). i can't do wordcloud2(wc, color = col) like an aes style call in ggplot, the wordcloud does draw but all the text is clear... i can hover over it but not see any of it. anyone else work through this issue? thanks!!!

Related

How can i change different colors between 5 categories when I use pd.qcut(df, 5) in a chart. f example: first 3 row = red, next 2 rows is blue,

here is the image of the code, someone suggest at I patch for each bin and use color mapping but I dont know how to do it

When does Excel use white font on tabs?

Excel uses black by default for the Font Color on the tabs. When you change the tab color, the Font Color remains black if the tab color is light, but changes to white when a darker color is chosen.
I would like to mimic this behavior. For which RGB combinations does Excel change to white Font Color?
Many thanks!
The possible colors of the tab are 256^3. Try it out for yourself:
Public Sub TestMe()
Dim cnt As Long
For cnt = 1 To 256 ^ 3 Step 10
ActiveSheet.Tab.Color = cnt
Next cnt
End Sub
I have followed the approach suggested by #Vityata. Excel behavior is not straight forward to replicate, but I have found an approximation that serve my purposes:
Considering the color cube as in:
http://matlab.izmiran.ru/help/toolbox/images/colorcube.jpg
Excel approximately uses white Font color when
R * 20132 + G * 64005 + B * 6630 <= 11675430
This will fail in some edge cases (eg: RGB(255,102,3)), but I still hope someone finds this useful. I am leaving the question open in case anyone founds an exact formula.
Thanks for the replies.

Syntax to set color of LED in sense-hat using nodered

I am working on sense-hat using node-red. I found that, to set the four corners of the display to red, green (#00ff00), yellow and blue (0,0,255):
0,0,red,0,7,#00ff00,7,7,yellow,7,0,0,0,255
But how to set color for 2 leds in column 2 and 3 of the LED panel in rows 2-7.
Can anyone please suggest me in this?
The sidebar help for the SenseHAT node describes the required syntax:
Format: <x>,<y>,<colour>
x and y must either be a value from 0 to 7,
a * to indicate the entire row or column,
or a range such as 3-6.
But how to set color for 2 leds in column 2 and 3 of the LED panel in rows 2-7.
If you want to set just two leds within those ranges then just pick two X/Y values within that range and set them.
2,2,red,2,3,red

What is the function of white in RGBW?

I have not been able to find much info on the RGBW color system, other than that the final W stands for 'white'. I thought you could form white perfectly well with just red, green and blue, so I do not understand the function of white here.
Searching StackOverflow, I've found this question about converting between RGB and RGBW. Both answers suggest this 'algorithm' for conversion:
// RGBW from RGB
R, G, B, W = R, G, B, min(R, G, B) // i.e. W=min(R,G,B)
// RGB from RGBW
R, G, B = R, G, B // throw away the W
This doesn't only look useless, it's also not true. My Android phone, running Cyanogenmod, has a light sensor that outputs RGBW (cat /sys/class/sensors/light_sensor/lux) and the white value is definitely not min(r,g,b). I've made a chart with the values:
(The X axis is time.)
The black line represents the white value (an actually white line would be rather difficult to see), the other colors are accurate (i.e. red line is the measured red value, etc.). From sight, I cannot determine any relation between white and the other colors, so it probably serves a function. I just cannot understand which.
It's this sensor: http://www.capellamicro.com.tw/EN/product_c.php?id=68&mode=16
And here is the source code that controls the sensor: https://github.com/mozilla-b2g/kernel-android-galaxy-s2-ics/blob/master/drivers/sensor/cm36651.c#L605-L630
That is all I've been able to figure out, but nothing contains info on what this white value represents.
That exactly it – you can't form white perfectly using only RGB LEDs. This is because the RGB colorspace is a small, pale fraction of the CIE-1931 XYZ space, and it’s distorted: incrementing an RGB values’ “R” by 1 is not at all qualitatively the same as incrementing its “G” value or “B” value, for example.
Just do a side by side comparison and the difference will be very, very clear. You can google “True white RGB led” and you'll learn a lot more; a good introduction is here: http://www.ledsmagazine.com/articles/print/volume-10/issue-6/features/understand-rgb-led-mixing-ratios-to-realize-optimal-color-in-signs-and-displays-magazine.html

Alpha blending a red, blue, and green image to produce an image tinted to any rgb value?

Basically, I have a context where I can't programatically tint an image, though I can change it's alpha value. With some experimentation, I've found that I can layer a red, blue, and green version of the image, with specific alpha values, to produce a wide range of colors. However, I am wondering if it's possible to achieve a true RGB representation through this method? If so, what is the formula for converting an RGB value into different alpha values for the red, blue, and green layers.
The basic "equation" of alpha combination is:
alpha * (R1,G1,B1) + (1-alpha) * (R2,G2,B2)
When you have three layers with alpha you are actually combining 4 layers (the 4th one is black) so the final color is:
alpha1 * (R1,G1,B1) + (1-alpha1) * (
alpha2 * (R2,G2,B2) + (1-alpha2) * (
alpha3 * (R3,G3,B3) + (1-alpha2) * (0,0,0) ) )
Provided you have the same image on each layer and layer1 is the red channel (G1=B1=0) and layer2 is green and layer3 is blue you get:
(alpha1 * R, (1-alpha1)*alpha2 * G, (1-alpha1)*(1-alpha2)*alpha3 * B)
For a white pixel you can do any possible color. For a black pixel you cannot do anything but black. For any other pixel, you are restricted by the values of R, G and B.
Say you wanted to achieve (Rd, Gd, Bd) at a pixel where the current color is (R, G, B) then you would have to choose:
alpha1 = Rd/R
alpha2 = Gd/(G*(1-alpha1))
alpha3 = Bd/(B*(1-alpha1)*(1-alpha2))
The problem is that alpha can typically only be between 0 and 1. So, for example, if Rd > R there is nothing you can do.
You can do better if you can control the blending function (for example, in Photoshop).
I don't think that's possible, if I understand you correctly.
If, for a certain pixel, your image's red value is, say, 0.5, you can combine that with an alpha in the (typical) range [0,1] to form any value up to and including 0.5, but you can't go above, to get e.g. 0.6 or so as the output value.
If you're looking to create 3 layers that blended together add up to the original image, it's quite possible. Here's a link to a Python script that calls functions in Paint Shop Pro to do the hard parts.
http://pixelnook.home.comcast.net/~pixelnook/SplitToRGB.htm
If you need more detail than that, leave a comment and I'll try to fill it in later.

Resources