Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase the font size of label names

Tags:

r

ggplot2

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"))
like image 722
ashraf Avatar asked May 04 '16 09:05

ashraf


People also ask

How do I increase font size in labels?

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.

How do I increase the font size of a label in HTML?

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.

How do I change font size in labels in Word?

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.

How do I increase the size of my headings?

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.


1 Answers

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"))
like image 159
Make42 Avatar answered Sep 21 '22 05:09

Make42