57,706 questions
1
vote
1
answer
30
views
R geom_contour_filled date scale
I have 3D data that are all dates. I want to plot them with a contour. I have almost what I want with geom_contour_filled of package ggplot2 but I struggle to obtain a decent legend as dates (I'd like ...
3
votes
1
answer
89
views
How to plot data like an animated ECG in R?
I have a 2 min data set sampled at 10 Hz that I want to plot like an ECG in R: I want to create a plot with a 30 s window, plot the first 30 s from left to right in real time, then after 30 s, the ...
1
vote
1
answer
97
views
stat_ellipse() in MCA plot does not cover jittered points / extends far beyond the data
I am creating a Multiple Correspondence Analysis (MCA) plot in R using FactoMineR, factoextra, and ggplot2. The goal is to add confidence ellipses around the archetype categories in the MCA space.
The ...
-1
votes
0
answers
67
views
R ggplot doesnt show every step of the scale [closed]
I'm using diamond dataset (tidyverse) and im testing some values with binwidth on the carat count and this is hapening.
This is the code:
ggplot(diamonds, aes(x = carat)) +
geom_histogram(binwidth =...
2
votes
2
answers
93
views
Reorder stacked bar graph by value [duplicate]
What is the easiest-to-replicate way of reordering these bar graphs (
group1, group2) so that it is arranged in ascending order of col3 from bottom to top? I am looking for a solution that can be used ...
1
vote
1
answer
64
views
Error with stat_pointinterval() associated with aesthetics [closed]
I have previously used the stat_pointinterval() function from the R package tidybayes to make plots of the median and credible intervals around model parameters.
While re-running code today, none of ...
3
votes
1
answer
117
views
Creating a plot for residuals
I have following linear regression model:
library(nlme)
library(lattice)
data(Orthodont)
model = lm( distance ~ age * Sex, Orthodont)
lattice::bwplot(getGroups(Orthodont) ~ resid(model))
However, I ...
1
vote
1
answer
78
views
Cropped polygon sf not filling plot area after being projected
I am running code that I previously used to create maps for my data. The background for the map is:
library(rnaturalearth)
library(sf)
countries <- ne_countries(scale = "medium", ...
0
votes
0
answers
25
views
Display category with zero categories in barplot [duplicate]
Here is my code:
group_composition <- turtle_data %>%
group_by(group) %>%
summarise(
n_turtles = n(),
n_male = sum(sex == "Male"),
n_female = sum(sex == "Female&...
3
votes
2
answers
130
views
Issue with SpatVector wrapping when plotting
When plotting a SpatVector using ggplot2, if I define a projection using coord_sf(), it adds these lines that I think come from the data wrapping around the plot extent. Best way to fix?
library(...
0
votes
1
answer
77
views
stat_regline_equation() doesn't match stat_smooth() line
I'm getting an odd problem where I've attempted to plot a scatter graph and fit a quadratic regression line to it. I used stat_smooth() to make the line, and stat_regline_equation() to print the ...
2
votes
1
answer
67
views
Graph with bars and points, trouble getting both into legend
This legend should have an additional event "Spring", which is represented by a point in the legend, that is below the information about the bars. I can't get this to show up in the legend. ...
-3
votes
2
answers
77
views
X axis labels are not in sync with the data in ggplot
I have below data and ggplot
dat = structure(list(date = structure(c(19722, 19388, 19691, 19447,
19508, 19600, 19722, 19630, 19691, 19874, 19813, 19874, 19813,
19874, 19813, 19813, 19874, 19874, ...
4
votes
2
answers
155
views
Align a dendrogram with faceted time series
I am doing some time series clustering, and would like to align the dendrogram with the time series shapes. This is almost there:
library(ggplot2)
library(reshape2)
library(stats)
library(patchwork)
...
4
votes
3
answers
227
views
Modify the gtable of a ggplot2 and end up with a ggplot2 object without loss of information
I'm trying to write an extension for ggplot2 in R that lets a user add text annotations in the margins. My idea is to put the text in new rows/columns that get added to the plot's gtable. Hopefully ...
8
votes
2
answers
290
views
How to draw a double line in ggplot
How do I make the line in the graph above a double line like shown in below?
Some example code:
df <- data.frame(dose=c("D0.5", "D1", "D2"),
len=c(4.2,...
4
votes
1
answer
112
views
How to avoid tooltip disappearing on click in ggiraph interactive plots?
In a Shiny application, using ggiraph to make a ggplot2 plot interactive, using geom_col_interactive() or similar to add tooltips to a plot element, tooltip appears on hover, but if the user clicks ...
1
vote
2
answers
110
views
ggplot2 + patchwork: making a plot background transparent when overlapping another panel
I am trying to compose a figure with multiple panels. I have a lot of empty space and I am trying to overlap some of the rectangular panels, so I can make some of them larger. However, setting in ...
0
votes
0
answers
60
views
Problems plotting CCA from phyloseq object
I am trying to produce a CCA graph from a large microbiome dataset of turtles that includes some additional information like diet and climate. I am trying to see how these factors influence microbial ...
0
votes
0
answers
88
views
How do I make space between polar bar stacks even?
I am making a stacked polar bar chart in ggplot2 and I think I reached a good result in the picture attached.
However, there is an annoying wider space at the top between the Chordata and Molluscs ...
0
votes
1
answer
90
views
how to get rid of the outer line in grid major in ggplot2?
When building a radar plot, I want to grid major to be drawn, but there is an extra line that is added even if I set the scale_y_continuous(breaks= c(0:5)+exp_lim). Is there a way to only draw the ...
2
votes
1
answer
77
views
Adjusting secondary y-values
I'm having trouble fixing my secondary y-values. I have a context plot showing my inputs and a results plot showing the outputs. But no matter what I do, the values on my secondary y-axis don't align ...
1
vote
1
answer
63
views
Combining lines in a predicted probability plot without changing the regression model
I have a dataset with a binary outcome income and two continuous predictors, age, and education_num. I'm fitting a logistic regression model with a natural spline for age and an interaction with ...
2
votes
3
answers
104
views
r - ggplot stacked area plot with NAs using geom_area
I'm creating a stacked area plot showing phytoplankton biovolume over time, and I have one year of missing data. I'd like my plot to show the break in the data as it would using geom_line, but I can't ...
2
votes
1
answer
98
views
ggbarplot mean standard error bars not aligning
I am trying to plot the percentage of three cellTypes (T cells CD4, T cells CD8 & Tregs) that are assigned to A vs B, averaged across the ROI_name column and with mean_se bars, however the plotted ...