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
0answers
21 views

How do I properly set up the legend to my linear mixed model using ggplot? [closed]

I have built a linear mixed effects model and I'm trying to plot it using ggplot but it keeps giving me problems with my legend. It's ordered wrong, or I get two ...
0
votes
0answers
9 views

Problem with Risk table in Kaplan-Meier plot [closed]

It is my first time here and I wish to as clear and kind as every user in this forum. I am trying to generate a Kaplan-Meier Plot for Overall Survival using survival and ggplot2 packages, with the ...
0
votes
0answers
4 views

How to define data when using ggsignif with grouped bar graphs and facet_wrap in R [migrated]

I'd like to ask a question about the ggsignif package in the R software. I want to display significant stars in top of paired bar graphs using facet_wrap and I'm following this thread https://...
1
vote
0answers
85 views

Poisson regression with offset - help with fit and visualization

My goal is to understand the relationship between the number of worms found in a plot of land and the percent silt that makes up the soil. The plots of land have been investigated to different extents ...
0
votes
0answers
13 views

How to plot dichotomous presence/absence data to complement timeseries data

I have a daily logger data for several variables. For this example I use 3 variables: precipitation, distance and I dichotomous variable (1/0) which is 1 if the precipitation is in the form of rain ...
0
votes
1answer
35 views

R prediction interval - two different methods get two different values

Does anyone know what I'm doing wrong here? I'm trying to get a prediction interval for a linear model using the mtcars dataset. I try two different methods and get two different answers. I'm all ...
0
votes
0answers
25 views

The ggpredict function returns incomplete confidence intervals for a linear mixed midel with an interaction

I am trying to create a plot showing the LMM prediction with confidence intervals using the ggpredict function from the ggeffect ...
0
votes
0answers
15 views

Calculating number at risk for Kaplan Meier analysis with staggered entry

I am trying to create KM curves in r on data from a telemetry project. The data is right censored and additionally not all individuals were tagged on the same day so they entered the study at ...
1
vote
1answer
40 views

Side by side bar charts using ggplot2 [closed]

I am a current undergraduate student working on my first small research project. I am trying to make 3 barcharts of percentages of experiencing racism side by side and I am having trouble with this. I ...
3
votes
0answers
66 views

Confidence intervals for binomial generalised linear model with cauchit link function

The correct way to calculate a confidence interval (CI) for a generalised linear model (GLM) and avoid the problems of normal approximation intervals has been adequately discussed by Gavin Simpson ...
0
votes
0answers
2 views

Including control in group factors

with data frame below: I would like to get the control data presented in in both chair and table treatments , how do I do that? mean_dataf Product week Type Treatment Quality 1 Furniture ...
1
vote
0answers
17 views

How do I draw polygons in a scatterplot around groups of points based on a factor other than the factor my colors are based on? [closed]

I pasted the data here: The dataframe contains multiple observations on x and y per country. Each country is also part of a region. Based on this post, I managed to draw ploygons/clusters in the ...
0
votes
1answer
66 views

Confidence band around regression line in R

I have a scatter plot that displays the trust in a country's scientists vs trust in scientists globally. based on data I created a scatter plot am trying to understand the confidence band in this ...
1
vote
0answers
63 views

Which NMDS axes should I plot?

I have been running some non-metric multidimensional scaling analysis on a bray-curtis dissimilarity matrix (using ecodist::distance()). Theory suggests that we ...
2
votes
1answer
190 views

How can I plot a hyperbolic curve in R and get an equation of best fit? [closed]

Is there anyway to plot this data set using ggplot2 to get a graph with a hyperbolic line of beset fit as well as the equation for the line? ...
0
votes
1answer
30 views

Showing the relationship between variables and drawing regression line

I am trying to solve a question which says: Use ggplot() to plot the graphs to see the relationship between variables GS with <...
2
votes
2answers
134 views

Probability distribution of a random variable

The table below shows the number of ice creams brought and the number of customers brought that number of ice creams. ...
0
votes
0answers
12 views

Is there a way to graph an interaction from a mixed effects model with covariates?

I am trying to graph the results of a week by condition interaction in a mixed-effects model with multiple covariates. Data is nested within-subject. I am predicting steps by week (factor with 5 ...
0
votes
0answers
19 views

Single plot to illustrate two linear mixed effect model in R

I have been analysing my longitudinal data using linear mixed effect model, each person measured at 2 time points. Because my time is binary (first and second month), I have created a two dataset (...
1
vote
2answers
69 views

How to have graphical vizualisation of this table in R?

Actually, I have this kind of table I want to summarize into a graphic in R (preferably with ggplot2). Where the first three columns are the possible combinations of three methods (where 0 is absence ...
1
vote
1answer
139 views

Plot predict probabilities wiht ggplot2 and brms [closed]

I'm a PhD student in psycholinguistics and I'm having trouble in modeling some ordinal data. I have an ordinal response (completely disagree, disagree, neutral, agree, completely agree) and two ...
-3
votes
1answer
18 views

Problems to plot this barchart [closed]

I'm analysing a dataset about the suicides in the world based on age and location. I don't understand why I can't plot this barchart properly. When I access the suicbc variable typing ...
0
votes
1answer
55 views

How to interpret the probability of a negative value in a density plot

I have the following density plot in R using ggplot ...
0
votes
0answers
49 views

Error when creating SVM plot in R: Error in UseMethod(“predict”) : no applicable method for 'predict' applied to an object of class “svm”

I am trying to create a plot for weighted SVM model The following commands: X <- subset(mydata, select=-STATUS) Y <- subset(mydata, select=STATUS) wts<-1/table(Y) best_model= svm(mydata, Y, ...
0
votes
0answers
26 views

How to fit a non-linear model to data using a predefined function

I tried to fit a Difference of Gaussians (DoG) function to my data that has a non-linear relationship. The DoG function is as follows: ...
-1
votes
1answer
42 views

Interpreting two linear regression outputs - one generic, one "faceted" (R, ggplot)

I am trying to analyse the potential relationship between Unemployment Rate and the occurrences of three types of crime (namely Anti-social behaviour, Theft, and Violence & Sexual Offences). First,...
1
vote
0answers
14 views

Am I interpreting this scatter plot correctly? ggplot in R [duplicate]

I am not sure if I am interpreting this scatter plot correctly. It's supposed to help analyse any potential relationship between unemployment rate and crime. X axis = crime occurrences (3 types of ...
0
votes
2answers
144 views

Beta regression fitted values

I have a beta regression model in R, have generated predicted (fitted) values based on my data, and plotted lines of those fitted values on a scatter plot of the actual data. I'm most used to GLMMs, ...
0
votes
0answers
20 views

estimaing OR from logistic regression with interaction in R

I am running a logistic regression with two explanatory variables x1 (0=No, 1=yes) and x2 (0=bad, 1=good), and the outcome y (0=alive, 1=dead). But I also want to test interaction between the two ...
0
votes
0answers
19 views

Non-linear relationship between x and y in panel data

I was expecting a positive relationship between the mean age and my dependent variable in my PANEL data set. However, when trying to fit a regression, the result was negative. When plotting the ...
0
votes
1answer
248 views

What is the difference between Rplot ACF and ggplot ACF?

I am using below two codes for plotting the autocorreleation of a time series, The data looks like below: ...
3
votes
1answer
50 views

Challenging visualization task: simultaneously visualizing 15 regions by 3 descriptive values

I have a rather challenging visualization task. 15 geographical regions (data points for plot), each described by 3 continuous values and all these values have confidence intervals. The aim is to ...
10
votes
2answers
217 views

Statistics on LOESS smoothing

I'm trying to make sense of a data set which contains thousands of independent measurements of intensity in the form of a scatterplot. These measurements are dependent on two major variables: ...
0
votes
0answers
14 views

Determining whether one variable is significantly different from multiple others in ggplot2

I have a dataset with the concentrations of six drugs for four diseases and eight participants ("Donors") in ±O2 conditions. I suspect that Donor 1 in my dataframe below might be an outlier ...
0
votes
0answers
55 views

2 D density plot interpretation and manipulating the data?

I have a data frame like this: ...
1
vote
0answers
28 views

Boxplot giving only points and no boxes [closed]

I have plotted two boxplots side by side from two different datasets in the same plot. I made some transformations first they had different number of observations. ...
0
votes
1answer
123 views

Plot correlation between random intercept and slope glmmTMB?

I am after some advice regarding how to plot the correlation between a random intercept and slope from a mixed model in glmmTBM? Below is a reproducible example. <...
2
votes
1answer
656 views

Plotting predicted values with lmer

I would like to plot a prediction graph in R using this model : ...
1
vote
0answers
80 views

Center ggplot2 output image around x-axis label [closed]

The plot below shows some data I collected. It was plotted and saved using ggplot2: ...
0
votes
1answer
30 views

All of my AU-PRC values are the same, is there something wrong with my code or models?

I have been doing some training of basic models for a certain binary outcome, and most of the training has been on optimizing the AUC. But when I plot the precision recall curves, I get essentially ...
0
votes
2answers
151 views

Interpretation of the Linear regression model using ggplot2

I used ggplot() for visualization and linear regression in R for this model. I am not confident if I interpreted the model right. These are my thoughts. The $p$-...
0
votes
0answers
27 views

How to evaluate which factor explains more of DV variance by eyeballing a violin plot

When glancing over data, I want to be able to quickly grasp which independent variable (factor) explains most of variance of a dependent variable (continuous). One way of reaching quick conclusions is ...
0
votes
0answers
28 views

Stuck on confidence interval analysis for GLM

I'm really new to R, and sort of stats in general. I've been using a GLM to analyse a series of data, which is basically tracking how concentrations of DNA change over time, when different treatments ...
2
votes
0answers
123 views

ggplot: help with interpreting standard error areas

I have made the graph below which shows the SE area around lines. However, I can't work out why they are so large for the 3rd graph. Graph code: ...
0
votes
1answer
275 views

Representing interaction plot for coxph model using plot_model() in R

I used coxph() to model the latency to a behavior as a function of the levels of a hormone in interaction with the treatment administered. Code for model is as follows ...
1
vote
1answer
115 views

how to get predicted intervals? code no giving me those values [closed]

I am doing a cross validation in a training data and I am getting my predicted values with my test data. I want to do a plot with predicted versus observed with the predicted intervals but my code is ...
1
vote
2answers
59 views

How should I color the dozens of curves in this plot?

I have 48 curves that I need to put in a single plot. Below is the current version of the plot; I made it using ggplot2. The curves belong to four groups; each group has 12 curves. I'd like to color ...
1
vote
1answer
214 views

Fitting a broken stick regression with confidence intervals

I have been trying to fit a scatter plot of a broken stick regression with confidence intervals. What I would like is to have two different regression lines and confidence intervals between the ...
0
votes
1answer
100 views

Plotting multiple binary glm lines

I'm trying to fit multiple lines on to one plot in R and I'c using code taken from https://stackoverflow.com/questions/36942443/plotting-a-multiple-logistic-regression-for-binary-and-continuous-values-...
1
vote
2answers
685 views

How do I interpret and visualise my linear mixed effects model lmer() in R?

this may be a beginners question but any help is appreciated! I'm looking to compare the length frequencies of fish caught by two different nets using a linear mixed effect model. In this study the '...

1
2 3 4 5