ggplot2

Adjust geom_point size so large values are plotted, but do not appear larger in ggplot2?

谁说我不能喝 提交于 2021-02-07 19:42:11
问题 The issue I am having is that I would like the points above a certain threshold (=<25) to not produce points larger than the set scale. These larger points still need to be displayed, and cannot be excluded: d=data.frame(y=c(1,2,6,4,4,6,7,8), x=c(8,4,7,5,4,9,2,3), coverage=c(0,6,9,88,25,22,17,100), col=c(0,.25,.50,.76,.80,1.00,.11,.34) ) ggplot() + scale_size(range = c(0, 13), breaks = c(0, 5, 10, 20, 25), labels = c("0", "5", "10", "20", "25+"), guide = "legend" ) + geom_point(data = d,

Adjust geom_point size so large values are plotted, but do not appear larger in ggplot2?

爷,独闯天下 提交于 2021-02-07 19:42:08
问题 The issue I am having is that I would like the points above a certain threshold (=<25) to not produce points larger than the set scale. These larger points still need to be displayed, and cannot be excluded: d=data.frame(y=c(1,2,6,4,4,6,7,8), x=c(8,4,7,5,4,9,2,3), coverage=c(0,6,9,88,25,22,17,100), col=c(0,.25,.50,.76,.80,1.00,.11,.34) ) ggplot() + scale_size(range = c(0, 13), breaks = c(0, 5, 10, 20, 25), labels = c("0", "5", "10", "20", "25+"), guide = "legend" ) + geom_point(data = d,

Adjust geom_point size so large values are plotted, but do not appear larger in ggplot2?

老子叫甜甜 提交于 2021-02-07 19:42:00
问题 The issue I am having is that I would like the points above a certain threshold (=<25) to not produce points larger than the set scale. These larger points still need to be displayed, and cannot be excluded: d=data.frame(y=c(1,2,6,4,4,6,7,8), x=c(8,4,7,5,4,9,2,3), coverage=c(0,6,9,88,25,22,17,100), col=c(0,.25,.50,.76,.80,1.00,.11,.34) ) ggplot() + scale_size(range = c(0, 13), breaks = c(0, 5, 10, 20, 25), labels = c("0", "5", "10", "20", "25+"), guide = "legend" ) + geom_point(data = d,

How to create a legend from scratch which is not in aes of ggplot2?

随声附和 提交于 2021-02-07 19:25:22
问题 Continue my question here: Variable line size using ggplot2 I can create a figure with these codes. x <- 1:100 y <- x * x z <- abs(cos(x * pi / (max(x)))) df <- data.frame(x = x, y = y, z = z) library(ggplot2) mult <- 200 ggplot(df, aes(x, y)) + geom_line() + geom_ribbon(aes(ymin=y-mult*z, ymax=y+mult*z)) But my question now is how to create a legend to reflect the size of line. For example, legend in this figure ggplot(df, aes(x, y, size = z)) + geom_line() Is there any way to and a legend

ggplot2: Exclude legend from aspect ratio

独自空忆成欢 提交于 2021-02-07 19:18:38
问题 I use ggplot2 and knitr to publish scatterplots with a right-hand-side legend. The legend is included in the aspect ratio and therefore breaks the "squareness" of the plots, as shown in the default themes. When the legend text becomes a bit longer than "a" and "b", the graphs become "long rectangles" instead of "squares". I would like to keep the graphs "squared", and so would like to exclude the legend from the aspect ratio on my ggplot2 graphs. My .Rprofile has the following information to

ggplot2: Exclude legend from aspect ratio

无人久伴 提交于 2021-02-07 19:17:57
问题 I use ggplot2 and knitr to publish scatterplots with a right-hand-side legend. The legend is included in the aspect ratio and therefore breaks the "squareness" of the plots, as shown in the default themes. When the legend text becomes a bit longer than "a" and "b", the graphs become "long rectangles" instead of "squares". I would like to keep the graphs "squared", and so would like to exclude the legend from the aspect ratio on my ggplot2 graphs. My .Rprofile has the following information to

use grid.arrange over multiple pages or marrangeGrob with a layout_matrix

ぃ、小莉子 提交于 2021-02-07 17:45:42
问题 i want to arrange plots with the following layout_matrix over multiple pages. rep. e.g. library(gridExtra) library(ggplot2) layout <- rbind(c(1,2,3,4), c(1,2,3,4), c(1,2,3,4), c(5,5,5,5)) p <- list() for(i in 1:15) { ifelse(i %% 5 > 0, p[[i]] <- ggplot(mtcars, aes(wt, mpg)) + geom_point() + ggtitle(paste("plot:",i)), p[[i]] <- tableGrob(mtcars[5:7,],rows = NULL) ) } if i have only one page: (easy) grid.arrange(grobs=p[1:5],layout_matrix=layout) if i want multiple pages: (i loose all my

gganimate returns .png files, but no animated object

微笑、不失礼 提交于 2021-02-07 14:41:48
问题 I am trying to create an animation to show students how to represent data with animations. Running the below code library(ggplot) library(gganimate) library(carData) anim <- ggplot(mtcars, aes(mpg, disp)) + transition_states(gear, transition_length = 2, state_length = 1) + enter_fade() + exit_fade() animate(anim) I was expecting an animation on a preview window and the creation of a gif image. Conversely, what I am getting is 100 .png files in the working directory, but nothing else. The

gganimate returns .png files, but no animated object

浪尽此生 提交于 2021-02-07 14:41:14
问题 I am trying to create an animation to show students how to represent data with animations. Running the below code library(ggplot) library(gganimate) library(carData) anim <- ggplot(mtcars, aes(mpg, disp)) + transition_states(gear, transition_length = 2, state_length = 1) + enter_fade() + exit_fade() animate(anim) I was expecting an animation on a preview window and the creation of a gif image. Conversely, what I am getting is 100 .png files in the working directory, but nothing else. The

gganimate returns .png files, but no animated object

那年仲夏 提交于 2021-02-07 14:39:29
问题 I am trying to create an animation to show students how to represent data with animations. Running the below code library(ggplot) library(gganimate) library(carData) anim <- ggplot(mtcars, aes(mpg, disp)) + transition_states(gear, transition_length = 2, state_length = 1) + enter_fade() + exit_fade() animate(anim) I was expecting an animation on a preview window and the creation of a gif image. Conversely, what I am getting is 100 .png files in the working directory, but nothing else. The