direct-labels

How to show directlabels after geom_smooth and not after geom_line?

心不动则不痛 提交于 2019-12-01 11:00:55
I'm using directlabels to annotate my plot. As you can see in this picture the labels are after geom_line but I want them after geom_smooth. Is this supported by directlabels? Or any other ideas how to achieve this? Thanks in advance! This is my code: library("ggplot2") set.seed(124234345) # Generate data df.2 <- data.frame("n_gram" = c("word1"), "year" = rep(100:199), "match_count" = runif(100 ,min = 1000 , max = 2000)) df.2 <- rbind(df.2, data.frame("n_gram" = c("word2"), "year" = rep(100:199), "match_count" = runif(100 ,min = 1000 , max = 2000)) ) # plot ggplot(df.2, aes(year, match_count,

directlabels: avoid clipping (like xpd=TRUE)

人盡茶涼 提交于 2019-12-01 04:10:12
In the plot below, direct label positions were tweaked a bit vertically, but they get clipped at the left/right edges. Is there any way to avoid clipping (similar to xpd=TRUE ) or adjust the clipped labels inwards in the plot frames? Here's the code for this example: library(car) library(reshape2) library(ggplot2) library(directlabels) library(nnet) ## Sec. 8.2 (Nested Dichotomies) # transform data Womenlf <- within(Womenlf,{ working <- recode(partic, " 'not.work' = 'no'; else = 'yes' ") fulltime <- recode(partic, " 'fulltime' = 'yes'; 'parttime' = 'no'; 'not.work' = NA")}) mod.working <- glm

R adding legend and directlabels to ggplot2 contour plot

浪尽此生 提交于 2019-11-30 12:39:59
I have a raster map that I want to plot using ggplot2 using a continuous scale and labeled isolines on top of that. For that I'm using the directlabels package and am close to getting what I want but I can't get both the legend and the labeled isolines on the same map The following code reproduces my problem: install.packages(c('ggplot2', 'directlabels')) library('ggplot2') library('directlabels') df <- expand.grid(x=1:100, y=1:100) df$z <- df$x * df$y # Plot 1: this plot is fine but without contours p <- ggplot(aes(x=x, y=y, z=z), data = df) + geom_raster(data=df, aes(fill=z)) + scale_fill

R adding legend and directlabels to ggplot2 contour plot

依然范特西╮ 提交于 2019-11-29 18:12:45
问题 I have a raster map that I want to plot using ggplot2 using a continuous scale and labeled isolines on top of that. For that I'm using the directlabels package and am close to getting what I want but I can't get both the legend and the labeled isolines on the same map The following code reproduces my problem: install.packages(c('ggplot2', 'directlabels')) library('ggplot2') library('directlabels') df <- expand.grid(x=1:100, y=1:100) df$z <- df$x * df$y # Plot 1: this plot is fine but without

How can I configure box.color in directlabels “draw.rects”?

时光总嘲笑我的痴心妄想 提交于 2019-11-29 05:05:59
Here is my working example: library(ggplot2) library(directlabels) # ver 2014.6.13 via r-forge DF <- expand.grid(z = seq(1, 3001, by=10), k = seq(from=0.5, to=5, by=0.25)) # Defines the function value for each z-k combination DF$dT <- with(DF, -0.07 * z * (1/2.75 - 1/k)) p <- ggplot(DF, aes(x = z, y = k, z = dT)) + theme_bw() + stat_contour(aes(colour=..level..), breaks=c(seq(from=-40, to=0, by=5), c(seq(from=5, to=150, by=10)))) angled.boxes <- list("far.from.others.borders","calc.boxes","enlarge.box","draw.rects") direct.label(p, "angled.boxes") Which looks like this: I want to turn the

Labelling points with ggplot2 and directlabels

 ̄綄美尐妖づ 提交于 2019-11-28 13:03:52
This is a follow-up to my earlier question . While the answer by krlmlr somehow helps to solve my problem, one issue remains - the labels are moved far away from the points such that it gets impossible to see which label corresponds to which point. Does anyone know how to fix this? Test data test <- structure(list(ID = c(183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 202, 203, 204 ), group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 10L, 1L, 1L, 11L, 1L, 10L, 10L, 1L, 1L, 1L), .Label = c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j",

How can I configure box.color in directlabels “draw.rects”?

人盡茶涼 提交于 2019-11-27 22:37:19
问题 Here is my working example: library(ggplot2) library(directlabels) # ver 2014.6.13 via r-forge DF <- expand.grid(z = seq(1, 3001, by=10), k = seq(from=0.5, to=5, by=0.25)) # Defines the function value for each z-k combination DF$dT <- with(DF, -0.07 * z * (1/2.75 - 1/k)) p <- ggplot(DF, aes(x = z, y = k, z = dT)) + theme_bw() + stat_contour(aes(colour=..level..), breaks=c(seq(from=-40, to=0, by=5), c(seq(from=5, to=150, by=10)))) angled.boxes <- list("far.from.others.borders","calc.boxes",

Labelling points with ggplot2 and directlabels

倖福魔咒の 提交于 2019-11-27 07:29:23
问题 This is a follow-up to my earlier question. While the answer by krlmlr somehow helps to solve my problem, one issue remains - the labels are moved far away from the points such that it gets impossible to see which label corresponds to which point. Does anyone know how to fix this? Test data test <- structure(list(ID = c(183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 202, 203, 204 ), group = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 10L,

Labeling Outliers of Boxplots in R

南笙酒味 提交于 2019-11-26 09:00:47
问题 I have the code that creates a boxplot, using ggplot in R, I want to label my outliers with the year and Battle. Here is my code to create my boxplot require(ggplot2) ggplot(seabattle, aes(x=PortugesOutcome,y=RatioPort2Dutch ),xlim=\"OutCome\", y=\"Ratio of Portuguese to Dutch/British ships\") + geom_boxplot(outlier.size=2,outlier.colour=\"green\") + stat_summary(fun.y=\"mean\", geom = \"point\", shape=23, size =3, fill=\"pink\") + ggtitle(\"Portugese Sea Battles\") Can anyone help? I knew