2016-07-02 149 views
0

我用下面的例子中我的問題: http://www.cmap.polytechnique.fr/~lepennec/R/Radar/RadarAndParallelPlots.htmly軸限制

mtcarsscaled <- as.data.frame(lapply(mtcars, ggplot2:::rescale01)) 
mtcarsscaled$model <- rownames(mtcars) 
mtcarsmelted <- reshape2::melt(mtcarsscaled) 

coord_radar <- function (theta = "x", start = 0, direction = 1) 
{ 
    theta <- match.arg(theta, c("x", "y")) 
    r <- if (theta == "x") 
    "y" 
    else "x" 
    ggproto("CordRadar", CoordPolar, theta = theta, r = r, start = start, 
      direction = sign(direction), 
      is_linear = function(coord) TRUE) 
} 

plot <- ggplot(mtcarsmelted, aes(x = variable, y = value)) + 
    geom_polygon(aes(group = model, color = model), fill = NA, size = 2, show.legend = FALSE) + 
    geom_line(aes(group = model, color = model), size = 2) + 
    theme(strip.text.x = element_text(size = rel(0.8)), 
     axis.text.x = element_text(size = rel(0.8)), 
     axis.ticks.y = element_blank(), 
     axis.text.y = element_blank()) + 
    xlab("") + ylab("") + 
    guides(color = guide_legend(ncol=2)) + 
    coord_radar() 

print(plot) 

我如何定義爲y軸的限制?目前,最低值將位於雷達圖的中間,零點不會顯示。我希望零在中間而不是中間/中心是最低值。

任何幫助非常感謝!

回答

1

我想通了,它只是與

scale_y_continuous(limits=c(0,10), breaks=c(1,2,3,4,5,6,7,8,9,10)) 

工作......但我不得不改變值到as.numeric提前。