[英]ggplot2: using the geom_area() function
我有一個數據框,其中顯示了每年四個類別,以及它們在該年總數中的各自份額。
> head(df)
class year share
1 class1 1975 0.806
2 class2 1975 0.131
3 class3 1975 0.018
4 class4 1975 0.045
5 class1 1976 0.788
6 class2 1976 0.151
在未指定fill
運行ggplot
時,將得到一個預期的統一灰色框。
> ggplot(df, aes(x=year, y=share, group=class)) + geom_area() + scale_fill_brewer()
所以我嘗試添加fill=class
,它不起作用。
> ggplot(df, aes(x=year, y=share, group=class, fill=class)) + geom_area() + scale_fill_brewer()
Error in inherits(x, "factor") : object "base_size" not found
In addition: Warning message:
In inherits(x, "factor") : restarting interrupted promise evaluation
>
我如何對class
因子進行處理才能使其與scale_fill_brewer()
一起正常工作? 顯然,該想法是根據圖的類別對圖的每個區域進行着色。
謝謝。
我只是有這個問題。 它接縫
theme_set(theme_bw(base_size=9))
導致報告錯誤。 但
base_size <- 9
theme_set(theme_bw(base_size=base_size))
作品。
我用Google搜索並在學習者博客中找到了示例
我不知道第一個例子什么不起作用?
問題出在我設置的某些主題參數上,所以一旦我開始構建可運行的示例以在此處重現,它就消失了。 謝謝您的幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.