簡體   English   中英

如何使用ggplot在條形圖中添加x軸和y軸值

[英]how to add x-axis and y-axis value in the bar chart using ggplot

這是我的代碼:

ggplot(data = samplesolution2, aes(x = transdt, y = transAmount, group = bankAcctID, fill = bankAcctID)) +
  geom_bar(stat = "identity") +
  geom_test(label = rownames(data), nudge_x = 0.25, nudge_y =  0.25, check_overlap = T) +
  ggtitle(label = "Showing Only Total Deposits Over $200") +
  facet_wrap(~ bankAcctID, ncol = 1) 

Error in geom_test(label = rownames(data), nudge_x = 0.25, nudge_y = 0.25,  : 
  could not find function "geom_test"

我想在每個欄中添加 x 和 y 值。

我認為你有兩個問題:

  1. geom_text中的錯字
  2. 您需要在調用rownames時使用 data.frame 的名稱,而不是“data”。
ggplot(data = samplesolution2, 
       aes(x = transdt, y = transAmount, group = bankAcctID, fill = bankAcctID)) +
  geom_bar(stat = "identity") + 
  geom_text(label = rownames(samplesolution2), nudge_x = 0.25, nudge_y = 0.25, check_overlap = T) +
  ggtitle(label = "Showing Only Total Deposits Over $200") +
  facet_wrap(~ bankAcctID, ncol = 1)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM