I want to increase the font size of label names. I tried with geom_label_repel(aes(label = names, label.size = 5), box.padding = unit(0.5, "lines"))
. But the size doesn't affect the labels.
ggplot(df, aes(x,y,label=names)) +
geom_point(colour = "red", size = 3) +
geom_smooth(method=lm, se=FALSE, colour = "blue") +
geom_label_repel(aes(label = names, label.size = 5),
box.padding = unit(0.5, "lines")) +
xlim(0,2.5) +
ylim(0,2.5) +
theme( plot.title=element_text(size=16,face="bold"),
axis.text=element_text(size=18),
axis.title=element_text(size=20,face="bold"))
To change the font size in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-size. HTML5 do not support the <font> tag, so the CSS style is used to add font size.
In HTML, you can change the size of text with the <font> tag using the size attribute. The size attribute specifies how large a font will be displayed in either relative or absolute terms.
If you want to use the Print button in the Labels dialog to send directly to the printer, you can change the font by selecting the text in the Address box, right-clicking it, and choosing Font from the context menu. You get the standard Font dialog to choose font, size, color, etc.
To change font size in HTML, use the CSS font-size property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.
As I just wrote in the comment, it is not clear from your code, whether you want the label size fixed (the same for all labels) or dependent on a column of df
. Guess you want it fixed. In that case, setting the size is not done within aes(...)
. Also, it is not necessary to repeat label=names
. After reading https://cran.r-project.org/web/packages/ggrepel/vignettes/ggrepel.html we can thus write:
ggplot(df, aes(x,y,label=names)) +
geom_point(colour = "red", size = 3) +
geom_smooth(method=lm, se=FALSE, colour = "blue") +
geom_label_repel(size = 5,
box.padding = unit(0.5, "lines")) +
xlim(0,2.5) +
ylim(0,2.5) +
theme( plot.title=element_text(size=16,face="bold"),
axis.text=element_text(size=18),
axis.title=element_text(size=20,face="bold"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With