Questions tagged [ggplot2]
ggplot2 is an actively maintained open-source chart-drawing package for R, written by Hadley Wickham, based upon the principles of "Grammar of Graphics". It partially replaces R's basic plot and the lattice package, while providing a clean, powerful, orthogonal and fun API.
ggplot2
56,844
questions
1
vote
1
answer
46
views
How to use average value in geom_line?
I am struggling to make a continuous line graph with bar plot.
I used the below code to make this graph.
Is there any way I can use geom_line with average value?
ggplot(df, aes(Date, Rain)) +
...
8
votes
1
answer
231
views
What does "training" the data mean in the internals of ggplot2?
I'm following along with the internals of the ggplot2 library and I'm trying to understand how non-positional aesthetics get mapped to the values that get passed to grid. The book describes this ...
0
votes
0
answers
40
views
Difference in the visual output of two images generated by the same R code
I know this is probably a very dumb question, but I cannot really understand this issue that has happened to me several times. In particular I will give you this example: I tried to generate a radar ...
2
votes
1
answer
20
views
geom_histogram cluster values with same fill category together
I'm trying to create a histogram which uses one column in the data set for the fill colour and another column in the data set for the groups. Both of these are define within the aes(). Then I add a ...
0
votes
1
answer
41
views
Add data table on x axis in ggplot in R?
I'm using R to make a combined barplot + line with ggplot2. I want to add a data table in the x axis just like it's possible to do in excel.
This is my data and the plot I managed to make:
graf4 <- ...
1
vote
1
answer
41
views
ggplot: how to have secondary y axis independent from the first?
I am trying to plot two lines with ggplot. The second line has a different scale and I would like to have a secondary axis for it, which is completely independent from the first.
I have already looked ...
1
vote
1
answer
26
views
ggplot access inherited data object in scale_y_continuous [duplicate]
I'm trying to access the data passed to a ggplot command in a scale_y_continuous 'layer'
diamonds %>%
filter(cut %in% c("Very Good"), carat > 2.8) %>%
ggplot(aes(x=table, y=...
3
votes
0
answers
39
views
Use own png for pictograms with ggplot2
I made a graph that uses water drop pictograms. Made this with geom_pictogram and used the pictogram from "FontAwesome5Free-Solid". However, I would like to switch to some pictograms I made ...
-1
votes
1
answer
32
views
Graph in ggplot2 within an environment
I have a question.
I found the following example code, at the link:
https://drsimonj.svbtle.com/mean-and-ci-plot-for-twoway-designs-using-ggplot2
Below the code:
library(dplyr)
library(ggplot2)
pd &...
0
votes
0
answers
21
views
How to calculate x-value when y reached a certain percentage? (Dose response curve)
I believe I have a rather simple problem but I cannot figure it out on my own, that is why I am asking you for help!
I have a dataset containing response curves over time from measurements of ...
1
vote
0
answers
32
views
geom_point adds extra point at y max
Creating a box plot in R using ggboxplot. Using geom_point to add individual data points and position = position_jitter(width = 0.2)) to spread them out.
The generated plot consistently adds an extra ...
0
votes
0
answers
22
views
Can you use an argument in a function to specify ggplot2 "fill" parameter? [duplicate]
I want to be able to define the fill= as one of the arguments in a function. First, here is what my tibble looks like:
> x
# A tibble: 16 × 6
popA popB genome chr1 chr2 chr3
<chr&...
1
vote
1
answer
24
views
Customization of plots created with the ale package
I started using the ale package that automatically generates ggplot objects from models. I would like to remove the labels "75%", "median" and "25%" that are ...
0
votes
0
answers
26
views
How to reorder catgorical axis for dot plot with error bars
Here is the plot I have, the data & the code
ggplot(data = TI, aes(y = VM, x = GeoM)) +
geom_point() +
geom_errorbar(mapping = aes(xmin = L95, xmax = U95), width = .75) +
geom_vline(aes(...
0
votes
1
answer
45
views
How do you add both data frame values and math operators to geom_text in R? [closed]
I'm attempting to use geom_text to create a label 'Ankle Absorption W = -0.52 - 0.13 x Hop Height'. My understanding is that I need to use %*% within expression() to output the x sign. The numbers are ...