簡體   English   中英

ggplot2 的 geom_bar() 沒有顯示默認的 x 軸刻度

[英]ggplot2's geom_bar() not showing default x axis ticks

作為一個簡單的例子,我將使用鑽石數據:

data(diamonds)

ggplot(diamonds, aes(x = clarity, y = carat, fill = cut)) +
  geom_bar(stat = "identity")

這將為我提供以下 output,其中 x 軸未注釋:

缺少 x 軸和 y 軸標簽

如何使 x 軸和 y 軸的值出現? 我一直在廣泛搜索,但還沒有找到解決方案......

對於我的真實數據集,我的 x 軸值是離散的,使用 scale_x_discrete() 不會改變結果。

預先感謝!

您的代碼工作正常,我相信您必須更新ggplot2並啟動新的R session:

data(diamonds)

ggplot(diamonds, aes(x = clarity, y = carat, fill = cut)) +
  geom_bar(stat = "identity")

在此處輸入圖像描述

暫無
暫無

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

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