-1

Producing a bar chart

library(ggplot2)
df <- data.frame(stock = c("google", "google", "amazon", "amazon", "amazon", "yahoo", "yahoo", "yahoo"), status = c("open", "close", "open", "buy", "close", "open", "buy", "close"), category = c("daily", "daily", "daily", "daily", "daily", "daily", "daily", "daily"), price = c(330379.36, 52324.62, 545240.22, 192574.83, 46721.34, 477658.62, 146724.44, 42721.78))
ggplot(df, aes(fill=stock, y=reorder(price, status), x= status)) +
     geom_bar(position="dodge", stat="identity") +
     ggtitle("Daily") +
     theme(axis.text.x = element_text(angle = 45, vjust = 0, hjust=0)) +
     geom_text(aes(label=price), position = position_dodge(width= 1), vjust=0.5)

How can someone change the size of text inside every bar and not all the size text of the graph?

foc
  • 947
  • 1
  • 9
  • 26
  • 3
    Are you trying to set `size` parameter in `geom_text` ? `geom_text(aes(label=price), position = position_dodge(width= 1), vjust=0.5, size = 3.3)` – Ronak Shah Jul 27 '20 at 10:21

1 Answers1

1

You can set size parameter in geom_text :

library(ggplot2)

ggplot(df, aes(fill=stock, y=reorder(price, status), x= status)) +
   geom_bar(position="dodge", stat="identity") +
   ggtitle("Daily") +
   theme(axis.text.x = element_text(angle = 45, vjust = 0, hjust=0)) +
   geom_text(aes(label=price), position = position_dodge(width= 1), 
                 vjust=-1.5, size = 3.3)

enter image description here

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213