ggplot2 Questions
2
Solved
Given the following plot:
library(tidyverse)
p <- ggplot(mtcars, aes(drat, disp)) +
geom_line()
p
layer_scales can be used (here) to extract breaks/break positions from most ggplot objects li...
2
Solved
I want to put confidence interval error bars for ggplot.
I have a dataset and I am plotting it with ggplot as:
df <- data.frame(
Sample=c("Sample1", "Sample2", "Sample3", "Sample4", "Sample5"...
4
Using facet_grid(), how can I place the group names, i.e. the grey strips, on the top of the plots when graphing the plots stacked vertically in a single column?
From what I have tried, when stacki...
Pukka asked 13/6, 2020 at 6:9
1
I have data from a study using a 2x2x3 repeated measures design. Participants provided a numeric response ('tcons') at two time-points (test: 'pre', 'post'). They were further grouped with respect ...
2
Solved
Using ggplot2 with geofacet, I want to outline some group of facets with rectangles. I guess I could draw it after the image is saved on disc as .png or .jpg with the magick package, but I would pr...
6
For a hydrologist, the Rainfall Hyetograph and Streamflow Hydrograph is commonly used. It looks like the figure below.
The X-axis represents Date and left Y-axis which is reversed represents rai...
4
Solved
I can add text to a ggplot using geom_text just fine (example using the cars database):
ggplot(cars, aes(speed, dist), color='blue') +
geom_point(size=0.8) +
geom_text(y=25, x=5, aes(label=paste...
3
Solved
Taking the graph from ggplot2 help pages:
ggplot(mtcars, aes(factor(cyl))) + geom_bar() + facet_grid(. ~ vs)
Is it possible to change the border (colour and/or thickness) of only selected panels...
1
Solved
I have data of a pre and a posttest in two groups: control and treatment. I computed the score and now want to illustrate the differences between groups and tests. As a basis I have a data frame in...
Lucretialucretius asked 26/8 at 10:54
5
Solved
I'd like to make a plot with a reversed, log10 x scale using ggplot2:
require(ggplot2)
df <- data.frame(x=1:10, y=runif(10))
p <- ggplot(data=df, aes(x=x, y=y)) + geom_point()
However, it...
4
I have the following code:
library(ggplot2)
data(mtcars)
ggplot(mtcars, aes(x=mpg)) + geom_histogram(bins=15, colour='red')
Which produce this:
As stated there, how can I change the thickness...
3
Solved
I am trying to combine percentage histogram with facet_wrap, but the percentages are not calculated based on group but all data. I would like each histogram to show distribution in a group, not rel...
Parisian asked 7/10, 2018 at 16:0
4
Solved
I have created the following ggplot to highlight my issue:
mydf = data.frame(x = c(1,2,3,4,5), y = c(1,2,3,4,5))
ggplot(data = mydf) +
geom_point(aes(x = x, y = y)) +
scale_x_continuous(labels...
2
Solved
I'm hoping to create a plot that shows a running average over a scatterplot of the observed data. The data consists of observations of hares' coat color (Color) over time (Julian).
Color Julian
5...
6
Solved
Let's say I want to make a histogram
So I use the following code
v100<-c(runif(100))
v100
library(ggplot2)
private_plot<-ggplot()+aes(v100)+geom_histogram(binwidth = (0.1),boundary=0
)+sca...
3
Solved
I am trying to draw an ECDF of some data with a "confidence interval" represented via a shaded region using ggplot2. I am having trouble combining geom_ribbon() with stat_ecdf() to achieve the effe...
5
Solved
I'm working with the pheatmap package. By default, it draws the plot to the screen. In my case, that means output in a R markdown notebook in R studio. But I also want to save to a file. If I save ...
2
Solved
I'm struggling with an additional label that I would like to add to my ggplot graph.
Here is my data set:
Group Gaze direction Counts Duration
Expert Performers game table 148 1262.122
Expert Per...
5
Solved
I've produced this map in ggplot2:
library(maptools); library(ggplot2)
data(wrld_simpl)
world <- fortify(wrld_simpl)
worldUk <- subset(world, id=="GBR")
ggplot() +
geom_path(aes(long, lat, g...
Phagy asked 17/6, 2013 at 15:17
2
Solved
I want to move the legend title sex a little right to the horizontal center of legend box. I tried theme and guide_legend but failed. Both ways won't change the legend title position.
# example da...
1
Solved
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 pr...
3
Solved
I am trying to produce a heat map using ggplot2. I found this example, which I am essentially trying to replicate with my data, but I am having difficulty. My data is a simple .csv file that looks ...
3
Solved
I have a line plot of prices for three stocks, which I normalise by taking the percentage change from the beginning of the period I am looking at. This seems to work fine, but instead of the colour...
7
Solved
Say I have a data frame and want to make a plot
df <- melt(iris)
p <- ggplot(data = df, aes(x = Species, y = value)) +
geom_boxplot() + theme(aspect.ratio = 1)
I then want to use ggsave...
Mirianmirielle asked 20/10, 2017 at 0:24
7
Solved
library(tidyverse)
ggplot(mpg, aes(displ, cty)) +
geom_point() +
facet_grid(rows = vars(drv), scales = "free")
The ggplot code above consists of three panels 4, f, and r. I'd like the y-a...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.