簡體   English   中英

ggplot2-更改功能圖中的線寬

[英]ggplot2 - change line width in function graph

說我有類似的功能:

quad <- function(x)
{
    return (x^2)
}

我使用ggplot

plot <- ggplot(data.frame(x=c(0,4)), aes(x = x)) +
        stat_function(fun = quad)

到目前為止,還算不錯,但是這條線確實很薄。 因此,我向該行添加了一些特定的幾何體:

plot + geom_line(size=2)

但它返回此錯誤:

錯誤:geom_line需要以下缺失的美感:y

如何在這種類型的圖中操縱線的幾何形狀?

玩了一段時間后,我發現可以將一個名為size的參數傳遞給stat_function 它具有與gem_line相同的效果:

plot <- ggplot(data.frame(x=c(0,4)), aes(x = x)) +
        stat_function(fun = quad, size=1.5)

暫無
暫無

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

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