Questions tagged [geom]

(aka Geometric objects in r ) A geom is the geometrical object that a plot uses to represent data in r. A ggplot2 geom tells the plot how you want to display your data in R. A geom defines the layout of a ggplot2 layer. People often describe plots by the type of geom that the plot uses. For example, bar charts use bar geoms, line charts use line geoms, boxplots use boxplot geoms, and so on.

224 questions
0
votes
0 answers

Geom_rect() removed after log2 transformation

(I am aware of a similar issue discussed here but not able to get these solutions to work) I used this code to successfully create this plot with a linear scale on the y axis. The important bit is the geom_rect() that creates the blue lines that…
M.J. Cox
  • 11
  • 2
0
votes
0 answers

plotly with interactive text does not plot with geom_line()

I have been playing wrangling the data in the package "gapminder" and produced an interactive plotly plot. But geom_line() does not work. Does someone know why and how to fix this issue? The code below works well-using geom_point() but once it…
0
votes
0 answers

R Ggplot2: Draw lines between unrelated points

I want to draw a line between some unrelated points. This is my code now: probpostest %>% filter(prev==15) %>% mutate( stat=replace(stat,stat=="prevalencia","Prevalencia"), …
jajb
  • 105
  • 7
0
votes
1 answer

Plotting a logistic regression line with ggplot: Warning message: Computation failed in `stat_smooth()`: unused argument (data = data)

I am trying to plot a binary regression line with ggplot and a real dataset for practice. The question: Is distance in kilometers a predictor for choosing a car as means of transport to get to the soccer stadium. The variable A2 was dichotomized (1…
pmyth
  • 25
  • 4
0
votes
1 answer

Geom_signif with 3 group comparison

I want to add a second comparison on top of my group comparisons using the geom_signif function. I have 3 subgroups and I am comparing the various subgroups for (C4). I want my final figure to look like this (attached). tgc4 < -…
0
votes
1 answer

ggrepel::geom_text_repel not working in large mode/Rstudio notebook output (nor with cowplot)

I was wondering if anyone knew why this is happening. Here is a quick example of the code and screenshots. library(ggplot2) iris$randomratio <- iris$Sepal.Length/iris$Sepal.Width plot_iris <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color =…
0
votes
1 answer

How can fit a curve to my data using ggplot that doesn't necessarily go through every point?

I'm trying to fit a curve to my data points in R, but geom_smooth is just drawing an ugly line through all the points. I'm looking for a way to make a smooth curve that doesn't necessarily go through all the points. and here is the code I used to…
College Kid
  • 53
  • 1
  • 6
0
votes
1 answer

how to increase of the Y axis to clearly display a boxplot

before I ask the question, I just want to say that I have looked every thread in here and I tried every trick in the book, but the problem remains,its due to the fact that I have 75 attributes of my variable CODEETAB (the school id) that I am…
user2161721
  • 164
  • 1
  • 2
  • 11
0
votes
1 answer

r - No line on plotting chart with ggplot using geom_line

I have the below table on data "data_temp" and I'm trying to plot a trend line using "geom_line", but line does not appear. > head(data_temp,15) Mês n 1 Janeiro 7432 2 Fevereiro 7077 3 Março 7494 4 …
Wil
  • 47
  • 4
0
votes
2 answers

Plotting individual observations and group means with facets with ggplot2

I'm trying to plot data from a study with three within-subjects (test item, frame, sample size) variables in ggplot. I have summarised and plotted test item on the x axis and have separate lines for sample size and have used facet_grid to separate…
Con Des
  • 359
  • 1
  • 2
  • 9
0
votes
0 answers

Formatting dumbbell plot and avoiding R Error: `f` must be a factor (or character vector)

I am trying to make dumbbell plots and want to arrange the plots in order. i.e. retention trials on top and transfer at the bottom.[! Someone suggested using "forcats ::fct_reorder" but I keep getting an error message "Error: f must be a factor (or…
0
votes
1 answer

Plot negative on logarithmic axis in ggplot

I followed this example and it works great for my data (https://r-graphics.org/recipe-axes-axis-log). Except I am also trying to add standard deviations and for one of the variables, the standard deviation is bigger than the mean. The figure just…
L55
  • 117
  • 8
0
votes
1 answer

geom_smooth not working for trendline, too few points?

I am trying to get a trendline for my two sets of averages, in my main graph I will be putting error bars on the points to show the sd's but below is a simplified version: ggplot(sl, aes(x=Stresslevel, y=Final, color=Treatment)) + geom_point() + …
0
votes
1 answer

How to extract the five numbers of geom_boxplot into a table?

I´m having some troubles trying to extract into a table the five number values of a geom_boxplot. I know it works easily with boxplot$stats, however, I cannot find the way to extract the same information from a boxplot made in ggplot2. Can anyone…
Paul Gis
  • 1
  • 1
0
votes
1 answer

geom_sf with continuous values and NA ggplot R

I have an sf-object that I would like to plot. It is a map over counties in Sweden (21 counties) and for each county, I have a value. This value however can be either a positive or negative value, or even an NA. I would like to plot the map over…
paula456
  • 101
  • 9