direct-labels

Direct labels puts labels at wrong place

。_饼干妹妹 提交于 2021-02-10 12:55:51
问题 I'm trying to do a plot with ggplot2 and trying to put labels at the right place on mean trajectories with confidence regions. Since I cannot share my data, I created a reproducible example: set.seed(456) library(ggplot2) library(directlabels) time<-1:25 df2<-data.frame(time,value=runif(2500),group=as.factor(c(rep('Alpha',1250),rep('Beta',1250)))) ggplot(df2, aes(x=time, y=value,group=group,colour=group))+ stat_summary(geom="ribbon", fun.data=mean_cl_normal,fun.args=list(conf.int=0.95), fill=

Selecting factor for labels (ggplot2, directlabels)

房东的猫 提交于 2019-12-21 21:50:33
问题 I'd like to use the package directlabels to label my plot. However, I'd like the label to be the ID of each point. Is there really no way to select which factor to label or did I miss that? library(ggplot2) library(directlabels) df <- structure( list(id = 1:10, group = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("A", "B"), class = "factor"), value1 = c(4, 1, 6, 2, 5, 7, 3, 2, 5, 8), value2 = c(6, 2, 6, 2, 8, 9, 7, 5, 2, 6) ), .Names = c("id", "group", "value1", "value2"),

How can you use directlabels and ggplot2?

两盒软妹~` 提交于 2019-12-20 13:35:27
问题 I'm trying use the directlabels package to label two lines I have in a simple plot (I'm using ggplot2) My code is as follows: # libraries library(ggplot2) library(directlabels) # Variables A = array(1000,100) F = seq(length=100, from=0, by=10) f = array(5,100) # make data frame 1 df <- data.frame(X = F * f/A, Y = F/A) # plot line 1 p = ggplot(df, aes(x=X,y=Y)) p = p + geom_line(colour="#56B4E9") # make data frame 2 df1 <- data.frame(X = F * f * 2/A, Y = F/A) # plot line 2 p = p + geom_line

How to show directlabels after geom_smooth and not after geom_line?

醉酒当歌 提交于 2019-12-19 09:58:21
问题 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

How to show directlabels after geom_smooth and not after geom_line?

╄→尐↘猪︶ㄣ 提交于 2019-12-19 09:58:12
问题 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

Add directlabels to geom_smooth rather than geom_line

好久不见. 提交于 2019-12-07 13:01:07
问题 I recognize that this question is a close duplicate of this one, but the solution there no longer works (using method="last.qp" ), so I'm asking it again. The basic issue is that I'd like to use directlabels (or equivalent) to label smoothed means for each group (from stat_smooth() ), rather than the actual data. The example below shows as close as I've gotten, but the labels aren't recognizing the grouping, or even the smoothed line. Instead, I'm getting the label at the last point. What I'd

Label size in directlabels geom_dl()

微笑、不失礼 提交于 2019-12-06 20:58:19
问题 I have really enjoyed the package directlabels for dynamic positioning the lables of a plot. Although still not perfect, it helps reasonably to prevent overlaps between labels of a scatter plots with many points for example - specially for the draft version of the charts, not the final one. However I can not find anyway to change the label size while using geom_dl() function. Is there anyway? I have tried to pass size and cex as a normal or aes() argument to the function. 回答1: Put cex inside

Label size in directlabels geom_dl()

白昼怎懂夜的黑 提交于 2019-12-05 02:06:45
I have really enjoyed the package directlabels for dynamic positioning the lables of a plot. Although still not perfect, it helps reasonably to prevent overlaps between labels of a scatter plots with many points for example - specially for the draft version of the charts, not the final one. However I can not find anyway to change the label size while using geom_dl() function. Is there anyway? I have tried to pass size and cex as a normal or aes() argument to the function. Put cex inside a list. Other formatting features should also be placed in the list. See some of the examples in

Selecting factor for labels (ggplot2, directlabels)

╄→гoц情女王★ 提交于 2019-12-04 16:41:18
I'd like to use the package directlabels to label my plot. However, I'd like the label to be the ID of each point. Is there really no way to select which factor to label or did I miss that? library(ggplot2) library(directlabels) df <- structure( list(id = 1:10, group = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("A", "B"), class = "factor"), value1 = c(4, 1, 6, 2, 5, 7, 3, 2, 5, 8), value2 = c(6, 2, 6, 2, 8, 9, 7, 5, 2, 6) ), .Names = c("id", "group", "value1", "value2"), row.names = c(NA, -10L), class = "data.frame") p1 <- ggplot(df, aes(x=value1, y=value2)) + geom_point

directlabels: avoid clipping (like xpd=TRUE)

家住魔仙堡 提交于 2019-12-04 00:24:46
问题 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' ")