ggpmisc

overlay of the legend of the estimated lines using the function stat_poly_eq

半世苍凉 提交于 2021-01-25 03:52:47
问题 I adjusted different models considering the response variable (massaseca) as a function of (tempo) for each treatment level (teor) using the ggplot2 function combined with the stat_poly_eq function. However, as can be seen in the graph below, the legends of the estimated lines are overlapping. I would like these to be stacked in the left corner. When using the stat_regline_equation function (label.y = 380, label.x = 1000) it is possible to move the legend, however, they are still superimposed

use npc units in annotate()

让人想犯罪 __ 提交于 2021-01-19 06:41:07
问题 I have a ggplot object. I would like to add some text with annotate() , and I would like to specify the coordinates of the text in npc units. Is this possible? This minimal example demonstrates how text is ordinarily positioned with annotate() : library(ggplot2) p <- ggplot(mtcars, aes(mpg, wt)) + geom_point() p + annotate("text", x = 30, y = 4.5, label = "hello") I would like to achieve the same effect, but instead of specifying x and y in native coordinates, I would like to specify them

use npc units in annotate()

不羁的心 提交于 2021-01-19 06:39:07
问题 I have a ggplot object. I would like to add some text with annotate() , and I would like to specify the coordinates of the text in npc units. Is this possible? This minimal example demonstrates how text is ordinarily positioned with annotate() : library(ggplot2) p <- ggplot(mtcars, aes(mpg, wt)) + geom_point() p + annotate("text", x = 30, y = 4.5, label = "hello") I would like to achieve the same effect, but instead of specifying x and y in native coordinates, I would like to specify them

Adding trend lines across groups and setting tick labels in a grouped violin plot or box plot

旧时模样 提交于 2020-07-23 07:39:08
问题 I have xy grouped data that I'm plotting using R 's ggplot2 geom_violin adding regression trend lines: Here are the data: library(dplyr) library(plotly) library(ggplot2) set.seed(1) df <- data.frame(value = c(rnorm(500,8,1),rnorm(600,6,1.5),rnorm(400,4,0.5),rnorm(500,2,2),rnorm(400,4,1),rnorm(600,7,0.5),rnorm(500,3,1),rnorm(500,3,1),rnorm(500,3,1)), age = c(rep("d3",500),rep("d8",600),rep("d24",400),rep("d3",500),rep("d8",400),rep("d24",600),rep("d3",500),rep("d8",500),rep("d24",500)), group

Adding trend lines across groups and setting tick labels in a grouped violin plot or box plot

﹥>﹥吖頭↗ 提交于 2020-07-23 07:38:08
问题 I have xy grouped data that I'm plotting using R 's ggplot2 geom_violin adding regression trend lines: Here are the data: library(dplyr) library(plotly) library(ggplot2) set.seed(1) df <- data.frame(value = c(rnorm(500,8,1),rnorm(600,6,1.5),rnorm(400,4,0.5),rnorm(500,2,2),rnorm(400,4,1),rnorm(600,7,0.5),rnorm(500,3,1),rnorm(500,3,1),rnorm(500,3,1)), age = c(rep("d3",500),rep("d8",600),rep("d24",400),rep("d3",500),rep("d8",400),rep("d24",600),rep("d3",500),rep("d8",500),rep("d24",500)), group

Adding trend lines across groups and setting tick labels in a grouped violin plot or box plot

我是研究僧i 提交于 2020-07-23 07:37:29
问题 I have xy grouped data that I'm plotting using R 's ggplot2 geom_violin adding regression trend lines: Here are the data: library(dplyr) library(plotly) library(ggplot2) set.seed(1) df <- data.frame(value = c(rnorm(500,8,1),rnorm(600,6,1.5),rnorm(400,4,0.5),rnorm(500,2,2),rnorm(400,4,1),rnorm(600,7,0.5),rnorm(500,3,1),rnorm(500,3,1),rnorm(500,3,1)), age = c(rep("d3",500),rep("d8",600),rep("d24",400),rep("d3",500),rep("d8",400),rep("d24",600),rep("d3",500),rep("d8",500),rep("d24",500)), group

Produce an inset in each facet of an R ggplot while preserving colours of the original facet content

青春壹個敷衍的年華 提交于 2020-07-05 04:56:40
问题 The bounty expires in 4 days . Answers to this question are eligible for a +50 reputation bounty. Apatura is looking for a more detailed answer to this question: I think I have a fundamental problem in combining facets, inlays and the correct colour scale. Please help to solve the colour issue inside the current partial solution, or if this isn't feasible, maybe another option. I think this is a useful graphic for many different situations. I would like to produce a graphic combining four

Label ggplot with group names and their equation, possibly with ggpmisc?

情到浓时终转凉″ 提交于 2020-06-28 05:43:11
问题 I would like to label my plot, possibly using the equation method from ggpmisc to give an informative label that links to the colour and equation (then I can remove the legend altogether). For example, in the plot below, I would ideally have the factor levels of 4, 6 and 8 in the equation LHS. library(tidyverse) library(ggpmisc) df_mtcars <- mtcars %>% mutate(factor_cyl = as.factor(cyl)) p <- ggplot(df_mtcars, aes(x = wt, y = mpg, group = factor_cyl, colour= factor_cyl))+ geom_smooth(method=

Can we neatly align the regression equation and R2 and p value?

别来无恙 提交于 2020-06-07 04:30:07
问题 What is the best (easiest) approach to add neatly to a ggplot plot the regression equation, the R2, and the p-value (for the equation)? Ideally it should be compatible with groups and faceting. This first plot with has the regression equation plus the r2 and p-value by group using ggpubr , but they are not aligned? Am I missing something? Could they be included as one string? library(ggplot) library(ggpubr) ggplot(mtcars, aes(x = wt, y = mpg, group = cyl))+ geom_smooth(method="lm")+ geom