Questions tagged [ggplot2]

ggplot2 is an enhanced plotting library for R based upon the principles of "The Grammar of Graphics". Use this tag for *on topic* questions that (a) involve `ggplot2` as a critical part of the question &/or expected answer, & (b) are not just about how to use `ggplot2`.

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 views

How do modulate the y-axis in R and GG-plot [closed]

All I have some code in R to make a graph. ...
Zayyan Masud's user avatar
0 votes
0 answers
10 views

Scatterplot in R doesn't fit in the screen - legend is not fully visible [closed]

How can I fix the problem in my scatterplots? Legend on top doesn't fit the screen properly. Some groups are not visible and the problem continues even if I zoom in or out. Should I add margins or ...
Sebnem K's user avatar
0 votes
1 answer
42 views

Visualize Cronbach's alpha in R Ggplot scatterplot as a regression line? [closed]

I'm looking for a way to make a scatterplot of the correlation between two questionnaires using Cronbach's alpha: Data: ...
Wandering_geek's user avatar
2 votes
1 answer
44 views

Summary output of binomial GLMM shows significant effects, but graph shows overlapping CI error bars?

I have run this binomial GLMM: ...
NeedHelpWithR's user avatar
0 votes
1 answer
18 views

Is GGeffects what I want to use to plot my linear mixed effect model results

So I am interested in how participants' own preference ratings for a series of items predicts their ratings for a peer's preferences for the same items. My model looks something like below where they ...
Shannon Cahalan's user avatar
1 vote
0 answers
24 views

Plotting custom logistic distribution

I'm trying to understand the logistic distribution and its application in a sports scoring model. The CDF of the logistic distribution is: $F(x) = {1 \over 1 + e^{-(x-\mu) / s}}$ I can then use ...
Daniel Westergren's user avatar
3 votes
1 answer
61 views

mgcv gam P-value vs plotted confidence intervals

I am trying to figure out how to explain the apparent discrepancy between P-values and plotted confidence intervals in mgcv. See for example the plot below that comes from a model that considers the ...
dean's user avatar
  • 333
0 votes
2 answers
26 views

What to plot when main effect significant but interaction insignificant?

This may be a silly question but: Given a regression model that includes both main effects and an interaction term (Score of participants predicted by their attitude and motivation): ...
a.henrietty's user avatar
3 votes
2 answers
64 views

What is the most responsible way to visualise non-response / NA data in a plot?

I'm working on plotting census data, which has a fairly high non-response rate for some questions (5% or higher). This could actually shift the way we interpret the results in quite significant ways (...
Jeremy Kidwell's user avatar
1 vote
1 answer
401 views

Visualising log odds from logistic regression model in R

I'm working on a logistic regression analysis using R and aiming to visualize the effects of the predictor "age" on the binary dependent variable "domestic violence." My dataset ...
user avatar
0 votes
0 answers
42 views

Should I run a linear or binomial regression based on my data distribution?

In the attached image, the x-axis is the proportion of children at a school who passed at least 5 GCSE exams that year, and the y-axis is a count of the schools. The different colours are whether the ...
Jess's user avatar
  • 21
1 vote
1 answer
121 views

How to fix this plot of histogram and pdf in R?

I am studying statistics and am working with R for the first time. I have some data that I am trying to represent it graphically. I have plotted a histogram and am trying to model it with gamma ...
Jesus's user avatar
  • 121
2 votes
1 answer
51 views

Is it appropriate to visualize multiple glm models (of different families) in the same plot?

I am assessing the effect of 5 predictor variables on species abundance. I have created 12 generalized linear models in R that have the same response and five predictors. Rather than run a complex ...
Angie Gonzalez's user avatar
0 votes
1 answer
55 views

Plot with multiple categorical predictors and before/after comparison

I have a dataset with 5 categorical variables that relate to before/after numerical data. I need to plot the relationship between the categorical data and the numerical results. Each category relates ...
Patricia Nunes's user avatar
0 votes
0 answers
135 views

What do the bars in ggdist::stat_halfeye() mean?

I am trying to understand what the black point, thicker horizontal bar, and thinner horizontal bar mean when I use the stat_halfeye() function. I can't find it on the package website. I'm pasting an ...
Benji's user avatar
  • 313
0 votes
0 answers
157 views

log axis display without transformation of data in ggplot?

p=ggplot(df, aes(x=logcon, y=res)) + geom_jitter(aes(y= (res),color=TRTGRP), width = 0, shape=1,size=1,height = 0.01) + geom_smooth(method="glm", se=T, method.args = list(family=binomial))+ ...
kamal's user avatar
  • 11
1 vote
0 answers
110 views

Interpretation of confidence interval using geom_smooth in ggplot2

I plotted data from two groups using geom_smooth in ggplot2. The default method loess was ...
cliu's user avatar
  • 211
2 votes
1 answer
208 views

GAM - parametric coefficients - what is mgcViz::pterm() actually plotting?

I built a GAM with two categorical variables and two smooth terms, following this structure: ...
mto23's user avatar
  • 637
0 votes
0 answers
31 views

Extrapolate 95% CI for unit decrease and for percentage decrease from lmer outputs

I am testing the association between percentage of impervious surface areas (ISA) and number of eggs per breeding event. This is my model structure: ...
Parus major's user avatar
3 votes
1 answer
247 views

Visualising scatterplot with too many points and two or more groups

I am trying to plot data with a large number of points. The goal is to see the basic distribution - location, dispersion, shape - of the observations. With a simple scatterplot, even with low ...
TY Lim's user avatar
  • 161
1 vote
1 answer
36 views

Holding covariates constant to plot MLR model on 2d scatterplot in R

I am currently working with a MLR model comprising 1 numeric/continuous predictor variable (x1), several nominal categorical variables (x2 ... xi), and an interaction term between the continuous ...
PhelsumaFL's user avatar
0 votes
2 answers
88 views

R conditional mutate within function [closed]

My function plots data and how the data is ordered depends on an argument of the function. The code looks unnecessarily repetitive but I can't figure out how to make the mutate() function (or any ...
achmed's user avatar
  • 35
1 vote
1 answer
165 views

How to interpret the partial effect plots for parametric terms while using gratia::draw() and gratia::parametric_effects()?

I am asking a question akin to this one: https://stackoverflow.com/questions/71884457/what-does-the-y-axis-effect-mean-after-using-gratiadraw-for-a-gam but am wondering the same question for ...
David Smith's user avatar
0 votes
1 answer
22 views

Gaussian Curve equation in R not peaking at zero [closed]

I have been analysing and plotting some different Gaussian curves in R to help me visualise them for a project I am working on. One such expression is the following: In R I have plotted this with by ...
AWGIS's user avatar
  • 83
0 votes
0 answers
32 views

Two way fixed effects proj r squared question

I'm currently testing out models for a research paper I'm doing as an undergraduate in political science. One of my questions of interest was whether rural turnout was higher than urban turnout at ...
user avatar
0 votes
0 answers
33 views

Interpreting cubic splines graph where plot doesn't go to final knot

I have this plot where I found that the best degree of freedom is 8, as it minimizes the SSE when predicted from the training data. However, the graph does not go into the final 8th knot in the spline....
Sam's user avatar
  • 1
0 votes
0 answers
120 views

Plotting all the points of PCA to only one PCA axis, first PC1 and then on the PC2

I am required to project all the points on PCA to PC1 axis and then on PC2 axis as to see whether there is a good separation between the points. Through this I have to determine which dimension can ...
Tshering's user avatar
1 vote
1 answer
38 views

How to code survival data so that sarting survival is below 1

I am analysing the time to the end of rehabilitation; however, not all patients receive rehabilitation. Therefore, for making Kaplan-Meier curves for the whole study population (including non-...
st4co4's user avatar
  • 2,077
1 vote
1 answer
441 views

Calculating Confidence intervals of marginal means for a linear mixed model using emmeans package

I have built this model in R: ...
Pashtun's user avatar
  • 93
0 votes
0 answers
41 views

How can I draw a interaction plot using trimmed means?

I am conducting two-way ANOVA in r using the t2way function in WRS2 packages for my thesis. t2way function, as you know, uses trimmed mean to escape from the severe problem of heterogeneity of ...
whra's user avatar
  • 1
1 vote
0 answers
34 views

Grouped Boxplots in R [closed]

I want to draw the same exact graph in R. However, I want to consider two options: (1) with one x axis for each of the genders & (2) two different xaxes for each of the gender. Here is also the ...
MK25's user avatar
  • 31
0 votes
1 answer
60 views

Troubleshooting linear mixed effects model plot and trendline slopes

I'm working with multiple years of temperature data from different sites in a watershed. I'm using the 7DADM measurements i.e. one temperature reading for each site per year of monitoring. This is ...
wRigglybean's user avatar
3 votes
4 answers
388 views

Are there any simpler alternatives to boxplots and barplots that can faithfully represent data with outliers and strongly varying ns?

I have a dataset of passwords that looks like this: My goal is to make a graph that accurately showcases the strength of each category so my initial plan was to group the data by category and ...
wageeh's user avatar
  • 241
4 votes
3 answers
175 views

Visualizing Categorical Response Data

I have a dataset that contains the "weight", the "gender" and if someone has "asthma" or not. I am interested in learning about ways to visualize the proportion of people ...
stats_noob's user avatar
1 vote
1 answer
75 views

Why does the confidence boundary contain fewer points than expected in R (`ggplot`)?

I use a LOESS regression and draw a confidence boundary with a 99% level. ...
Julien's user avatar
  • 150
0 votes
0 answers
245 views

Drawing Q-Q plot with ggplot2 and interpreting it

I'm learning how to draw Q-Q plots using R from Modern Statistics with R . The codes below compare the msleep$sleep_total data with a normal, lognormal, and a ...
Nownuri's user avatar
  • 409
0 votes
0 answers
63 views

What about the tails of a ggplot line graph?

Here is my data with value (numeric), group (A/B), Time (T1,T3), and Condition (neutral/reward) variables. ...
helloiambrain's user avatar
0 votes
0 answers
240 views

In a figure of emmeans, indicate effect size of contrasts as "significance stars"

I have an emmeans object of a logistic regression model (glmer). I made plots with ggplot2, ...
Raoul Van Oosten's user avatar
0 votes
0 answers
50 views

Precipitation to Mean Temperature Relationship

Based on the data below, I am trying to see if there is any relationship between Precipitation and Mean Temperature. Now the <...
Ed_Gravy's user avatar
  • 111
0 votes
1 answer
130 views

Statistical analysis of a bioassay

I am analyzing data on some biossays and I need an advice on which statistical analysis to use and how to use ggplot2 R package to better visualize the results. As you can see in the above image I ...
user avatar
23 votes
5 answers
5k views

How should we do boxplots with small samples?

This question is inspired by this posting, plus a comment by @StephanKolassa and an answer by @dipetkov who point out that the boxplots presented in that question are misleading. As is pointed out, ...
Russ Lenth's user avatar
  • 19.3k
0 votes
1 answer
526 views

Add straight-line in ggplot with date on the x-axis [closed]

I have below ggplot. ...
Bogaso's user avatar
  • 861
1 vote
0 answers
103 views

Finding statistical significance difference using Z score test using r

I wonder how to perform the z proportion test to check which COG category of Shewanella_sp_Alg231_23 is significantly high p (<0.05) from other genomes. To undersatnd I have attached a bar braph. <...
umar's user avatar
  • 111
3 votes
1 answer
1k views

Why do arrows of PCA graph have different angles between biplot and ggplot functions?

I'm using R iris data to show my point: pca = prcomp(iris[,-5],scale=F) png('irisNS_biplot.png',600,600) biplot(pca) dev.off() ...
Rodrigo's user avatar
  • 339
1 vote
0 answers
52 views

how to interpret this interaction (regression) [closed]

So, I have model: y = x + gender(categorical variable) + interaction(x and gender) x and gender and interaction was all significant and the plot y and x and gender. (this is simulated data without ...
yoo 's user avatar
  • 129
2 votes
2 answers
2k views

What is the best way to visualise a panel regression?

Simple scatter plots or a correlation matrix can be misleading since they aggregate all years together. What would be te best way to visualise relationships between variables taking time into account? ...
Peter Jordanson's user avatar
3 votes
1 answer
2k views

What do ggplot's stat_summary errorbars mean?

Say we have the following data: ...
elidomx's user avatar
  • 33
2 votes
1 answer
130 views

Why do my model visualization and model estimates not match (R, ggplot)?

I am studying the relationship between government fiscal balances (BAL) and bond yields (LTINT). I have a simple regression discontinuity model with a numerical variable (BAL), a dummy (SGP: breach/...
laurenstrie's user avatar
1 vote
0 answers
327 views

Plot multiple lines in transparent gray such that overlapping parts are darker [closed]

Unfortunately I cannot remember where I saw it, so I cannot provide a picture of how the plot should look like. I can just describe it: Do you know a way in MATLAB or R to plot multiple time series in ...
stollenm's user avatar
  • 832
1 vote
1 answer
2k views

R: Plotting lmer confidence intervals per faceted group

I am using lme4 package to run a Mixed-Effects Model followed by the predict function ot obtain fitting lines per invidual level and group level. Yet, I am ...
Diana Ortega's user avatar

1
2 3 4 5 6