When I use numbered colors in wordcloud2, nothing is displayed.
library(wordcloud2)
wordcloud2(demoFreq,color='blue1')
Color names without numbers are ok. E.g. color='blue'
What am I missing?
Since the word cloud is being rendered in HTML, you need to use html colors. blue1 is an R color, not HTML, so you need to convert it to a hex value color. the R function col2rgb will give an RGB triple, but that will not work with HTML. You need to convert the triple to a hex value. You can do that using rgb. However, rgb expects 3 columns, not a column of 3 values, so use t to transpose the RGB values.
rgb(t(col2rgb("blue1")), maxColorValue = 255)
[1] "#0000FF"
Now you can successfully call wordcloud2
wordcloud2(demoFreq, color=rgb(t(col2rgb("blue1")), maxColorValue = 255))
Probably HTML color codes are meant by "numbered colors", e.g.
wordcloud2(demoFreq, color= "#0080CC")
When "blue1" is not defined anywhere wordcloud2() has no color to use. But you could define one yourself.
library(wordcloud2)
blue1 <- "#0080CC"
wordcloud2(demoFreq, color= blue1)
Note that there are no quotes "" in this case.
There are more color names available here. The package itself defines 'random-dark' and 'random-light' in addition.
Edit: According to #GW5's comment use following code to obtain exactly the desired "blue1"as a workaround:
blue1 <- colors()[27]
wordcloud2(demoFreq, color= blue1)
Related
I'm trying to create a list of labels that contain italics. I can do it with "expression" like this, and when I put them on a plot (by adding a legend as an example, but I'll use them different ways), it all works nicely.
sp.names=c(expression(paste("species ",italic("one")," sp.")),
expression(paste("species ",italic("two")," sp.")))
plot(1:10)
legend("topleft",legend=sp.names)
But instead of specifying the words in the label directly in the code, I want to call them from cells in a dataframe (because there are a lot of them and they change depending on my underlying data). But when I try and specify which dataframe cell I want, it doesn't print the labels correctly (see below). Perhaps there is a different way for me to call the cell that I want that the "expression" function will recognise?
df=data.frame(V1=c("species","species","species"),V2=c("one","two","three"))
sp.names=c(expression(paste(df$V1[1],italic(df$V2[1])," sp.")),
expression(paste(df$V1[2],italic(df$V2[2])," sp.")))
plot(1:10)
legend("topleft",legend=sp.names)
Use substitute, it substitutes variables in expressions.
sp.names=c(substitute(V1 ~ italic(V2) ~ "sp.", df[1,]),
substitute(V1 ~ italic(V2) ~ "sp.", df[2,]))
I also removed the unneeded paste (which has a different meaning within plotmath) and replaced it with ~ for increased readability.
Give bquote a shot.
sp.names <- c(bquote(.(df$V1[1])~italic(.(df$V2[1]))~" sp."),
bquote(.(df$V1[2])~italic(.(df$V2[2]))~" sp."))
plot(1:10)
legend("topleft", legend=sp.names)
How can I write single-storey ɑ (The first letter in English) in Gnuplot graph title?
I am always get "a" (double-story) in Gnuplot plot title?
Suggesting to use the Greek letter alpha "ɑ" is not a good solution.
The correct answer is that the shape of the "a" glyph is dependent on the font, not the encoding. Unicode codepoints only specify what character is to be drawn, not what shape it has.
It depends on the terminal you want to use, but probably the most straightforward solution would be to use proper encoding and paste the required character directly:
set encoding utf8
set term wxt font "Times,12"
set title 'ɑ'
plot x
EDIT:
the special character ɑ can be also specified (for example in the interactive Gnuplot console) in terms of its UTF8 representation (two octal numbers) as:
set title '\311\221'
I only use lubunutu and do not use ubunutu.
In lubuntu CharacterMap utility exists and it can be used from accessory category.
On ubuntu, the same tool exists.
https://help.ubuntu.com/community/CharacterMap
I could copy and paste Lattin Small Letter alpha "ɑ" to terminal.
(Note that is not literally single-storey version of a).
As Ethan wrote use of Lattin Small Letter alpha "ɑ" is not correct in literal sense but I think this is possible workaround.
Correct solution is use font with single-storey a like Futura font.
Free Futura font seem to be available from
http://www.webpagepublicity.com/free-fonts-f4.html#Free%20Fonts
I'm using VIM in red hat 5, with the black background and green letters. However, I don't like the color schema for strings ("") nor reserved C++ key variables (int for example it is in dark green). Could someone please give me some suggestions how could I change those default colors?
I know, for example, to change the comment collor I do
hl Comment ctermfg=yellow
Type :hi, then hit Enter. A list of highlighting definition will show.
The C++ groups start with c.
int is a cType. Try:
:hi cType ctermfg=yellow
You can put your custom highlighting commands into vimrc(after colorscheme name and syntax on).
If you'd want to customize your current colorscheme, check out this Vivify. Adjust the color editor to your specific language and then save the colorscheme file into your vimfiles.
Is there any way to convert a string to hexa and then to convert it to a .Net color?
I would like to know how to convert a string of color ,say Black, to its Hexa '#000000' ?
i.e. if my input is "Black", i should return "#000000"
My issue is:
i'm setting color and storing its name in an object. So, if it is white, the object keeps "white" ,but for certain shades, it is keeping the name as f12a12 ( an example). I appended "0x" befor such strings and it worked fine with the colortranslator. In case of the normal colors in Color object, i dont want to append this. I can make the string to search through the Colors but i would like to know whether there is any other way to do this?
Color c = Color.Black;
string strColor = System.Drawing.ColorTranslator.ToHtml(c);
//returns 000000
Edit:
In reverse
Color c = System.Drawing.ColorTranslator.FromHtml("#000000");
There is no way to get the HEX from the color name. You need to create a lookup table which holds the name of the color and also the HEX of that color. And only then you can get the HEX of that color.
For your solution I am not sure, but I think to get the correct RGB values you need to have HEX of that color.
ColorTranslator.FromHtml( "#ffffff")
I have implemented a QColor dialog box which opens on certain condition. To get the selected color after final selection I use the method selectedColor() which returns the value in QColor. When I print that value, it's like this:
<PyQt4.QtGui.QColor object at 0x01DD7880>
I want color value in hex value like this: #DFDFDF (for grey). If it's not hex, correct me.
Is there any function to convert that?
Any suggestions welcome.
You need to print selectedColor().name() to print the actual color value in hex. See the QColor Documentation
To amplify a bit, maybe confuse, maybe clarify... (For Python newbies)
color = QColorDialog.getColor(pWidget.textBackgroundColor(), pWidget, 'Get Text Highlighting Color')
The above will return a QColor using the QColorDialog, for those of us who don't want to be stuck with named colors like 'Blue', 'red', green etc.
fg = color.name()
In this case I am converting the QColor to a string HEX for use in a style sheet.
Widget.setStyleSheet('background-color: ' + bg + ';color: ' + fg)
This is how such a converted value can be used in a style sheet.
Note how to concatenate more than one stylesheet attribute. Also, side note, sometimes changing one attribute cancels previous changes to others.