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
1
vote
1 answer

geom_sf: plot multiple series

I have a sf polygon dataframe with multiple series (T1, T2, T3, all on the same scale: they're observations at different time points). I can plot say T1 with ggplot(map)+geom_sf(aes(fill=T1)) what I'd like to do is plot all three (T1, T2 and T3) as…
Phil Viton
  • 41
  • 1
  • 7
1
vote
1 answer

R ggplot scale_fill_manual using colors for values within a range

I'm just hoping to clean up my code and learn a thing or two. I feel like I'm making this more difficult than it should be. I have a range of data from 0-9 and I would like to specify a color for values in that range. For example: 0-3 green 4-6…
Jakeeln
  • 353
  • 1
  • 4
  • 14
1
vote
1 answer

where can I find the complete list of shapes and colors as character inputs for geom_point?

p <- ggplot(mtcars, aes(wt, mpg)) p + geom_point(shape = "square", color = "blue") I have a function that will accept the shape and color parameters, which will be passed to geom_point. I need to check if the input is valid. So I need to do…
1
vote
1 answer

How is proportion computed with aes(group = x) in geom_bar?

I'm wondering how the proportion on the y-axis computed with the following code: library(ggplot2) ggplot(data = diamonds) + geom_bar(mapping = aes(x = cut, y = stat(prop), group = color)) Here is the output plot. I know there's a post about the…
chaoh
  • 13
  • 3
1
vote
2 answers

Add an additional staple to geom_col with value zero R

I have a dataset of different species and different damage. As you can see in my data, I only have two different "damages" in my code, but in a matter of fact, I got three different "damages". I want to plot my data and for each Species (Wolf, Bear,…
paula456
  • 101
  • 9
1
vote
2 answers

How to format line size in ggplot with multiple lines of different lengths?

I am able to make the plot correctly, but I would like to increase the line sizes to make the plot more readable. When I try size inside the geom_line, my lines get super fat. I have three time series variables (x,y, z) in the dataframe "data",…
j_t
  • 33
  • 1
  • 4
1
vote
0 answers

How to filter points in postgres?

I have a table with points in the Postgres. The points are from the flight path. I need to filter out some points. . My question would be how can I select only points which are in line and then make a line from the selected points only if parallel…
markus
  • 81
  • 7
1
vote
1 answer

How to change transparency in geom_flow ggplot?

I am trying to change the transparency of the flow elements of an alluvial plot. I know I should change the value of 'alpha' but I am not sure where in the code I have to add this parameter. The following is my…
1
vote
1 answer

ggtree highlight clades behind

I am working on a phylogenetic tree with R package ggtree and want to highlight nodes. My tree is stored in p, and the node I want to highlight is in G10. p <- ggtree(tree, right=T, layout="circular") G10 <- findMRCA(tree,…
Hkam
  • 11
  • 2
0
votes
2 answers

How can I change the width of a geom_xspline() in R? (ggplot / ggalt)

I am trying to plot a smoothed trendline but for various reasons I cannot use geom_smooth() to achieve my goal. The data is in the format: time value Group 1 124 1 1 452 2 2 49 1 2 453 2 3 788 1 3 652 2 4 356 1 4 452 2 The…
swediot
  • 19
  • 4
0
votes
0 answers

geom_smooth lines begin at zero

I have simulated some data in R to simulate disease prevalence curves. I would like the data to plot as a smoothed curve, so in ggplot2 I have used the function geom_smooth. The problem is that I would each of the lines to begin at x&y = 0, but…
bellbyrne
  • 67
  • 7
0
votes
0 answers

Adjust line alpha in geom_smooth

Hello I have the following question about ggplot and geom_smooth. How do I get it so that the individual lines are less visible, so adjust the alpha so to speak. Unfortunately alpha here only changes the visibility of the CIs. How can I still adjust…
0
votes
1 answer

Coordinating colour and shape in legend and plot consistently using geom point and line

Trying to create graphs using ggplot2, and I am coming with a strange peoblem I can't seem to solve. I've looked at other answers on stack overflow but they don't seem to fix the problem. Between different samples, the colours and shapes used in the…
0
votes
1 answer

How to create a function in R to add NBER recession shades to different facets in ggplot?

Let's say I want to plot the same time series (for example, stock prices) for different stocks using ggplot, all of them with free scales since the precise timing and magnitude of these stock prices are allowed to be different across stocks. That is…
Raul Guarini Riva
  • 651
  • 1
  • 10
  • 20
0
votes
1 answer

How to customize the plot.background in ggplot with multiple colors

I want to customize the plot background into different colors. Specifically, I want the background to be navy at the top and gray everywhere else, even though I want the plot itself to be white (i.e. overlaid onto the background). I've tried making…