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
1
vote
1answer
24 views

Plotting predicted values with lmer

I would like to plot a prediction graph in R using this model : ...
1
vote
0answers
12 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
0answers
25 views

Trying to understand confidence levels in geom_smooth

Please plot the following code: ggplot(iris, aes(x = Petal.Width, y = Petal.Length)) + geom_point()+ geom_smooth() One can see all the data points plotted, as ...
0
votes
1answer
12 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
1answer
30 views

Interpretation of the Linear regression model using ggplot2

I used ggplot for visualization and linear regression for this model. I am not confident if I interpreted the model right. These are my thoughts. P-value is large and R-squared is fairly small which ...
0
votes
0answers
25 views

Calculating upper and lower confidence limits in R (99% and 95%) for a funnel plot that does NOT look at rate

I am a programmer but not a statistician. I am trying to create a funnel plot in R that looks at average chest tube duration for each individual hospital in hours. The x-axis has the total number of ...
0
votes
0answers
26 views

How to add y position to stat_pvalue_manual after using emtrends to pairwise compare slopes

I've used emtrends to do a pairwise comparison of slopes. Ultimately I'd like a histogram with group on the x-axis and slope on the y-axis. I'd like to display the p-values for pairwise comparison of ...
0
votes
0answers
21 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
21 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
20 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
0answers
94 views

effect_plot, ggpredict, ggeffect: how to appropriately plot predicted values for a multiple linear regression?

I have a linear model with one main predictor of interest (GABA) and three covariates of no interest (BMI, Sex, Leg.Length): ...
0
votes
1answer
50 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
42 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 ...
0
votes
0answers
32 views

Adding confidence intervals to cumulative plot

I don't know why my question was closed previously. So I post it again and added some clarification. Hope this one is better! What am I doing? I want to plot the empirical cumulative probability of ...
1
vote
2answers
47 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
27 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
14 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
67 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 '...
0
votes
0answers
29 views

Performing a shapiro-wilk test on residuals from an LMER and repeated-measures ANOVA

I would like to perform a Shapiro-Wilk test on my data which takes the form of an LMER. The LMER model is named lmerabsolute. ...
0
votes
0answers
19 views

Plotting the effect of more predictors over a dependent variable in GLMs

I want to plot the effect of the predictors considered (V1, V2....Vn) over a dependent variable based on the following results obtained from the summary of GLM (negative binomial distribution): ...
0
votes
0answers
7 views

independent variable with two levels having one level tested two times (other level sandwiched between) for each individual in R using lme

I am trying to run lme (nlme package) analysis on a dataset where each individual (insect) is tested against two gas levels(Air, hypoxia) over time. Dataset Dependent variable cycle Independent ...
0
votes
0answers
117 views

Visualising high dimensional data

My data is of the form $(x,y)\in\mathbb{R}^{20}\times\mathbb{R}$ where I denote the components of the independent variable $x=(x_1,...,x_{20})$. The $y$ variable is just a binary variable, $y\in\{0,1\}...
0
votes
1answer
36 views

Panel data OLS regression: plot and quadratic fitting line

I am conducting an OLS regression panel data analysis with package PLM in R. I use the following script to obtain a plot and fitting line of variables D and ...
1
vote
0answers
36 views
1
vote
1answer
316 views

Find axis intercept using ggplot [closed]

I'm currently doing an assignment using R about the photoelectric effect - for those who don't know, the y-axis intercept of the straight line created by the data is the work function ($\phi$) of the ...
5
votes
2answers
251 views

Explanation of centralityPlot in qgraph

I am using this code to get a centralityPlot. ...
1
vote
0answers
41 views

Plot Actual vs Predicted SVM Regression

I am building an SVM regression model using caret package, however, I am not sure what is the best approach to plot predicted vs actual values. I have the code below. You can reproduce the output by ...
2
votes
1answer
118 views

R density plot: Why are maximums points different in log scale versus linear scale?

I have data with around 25,000 rows myData with column attr having values from 0 -> 45,600. I am not sure how to make a ...
0
votes
1answer
324 views

How to use a custom method in ggplot2 for fitting smooth line [closed]

In normal cases we would have something that resembles ggplot(data=data.frame)+ geom_point(...)+ geom_smooth(...,method="lm") However, I do not want to fit a ...
0
votes
1answer
38 views

Best visualization for distributions at multiple time steps

I have a set of discrete observations at multiple time points (~40) all of which are at similar scales i.e., between 0 and 10, and have been trying to determine the best visualization to show the ...
1
vote
1answer
23 views

Plotting series of numbers while protecting privacy

I have 2 series of numbers e.g x=[1,3,4,6,9] y=[100,179,210,400,650]. I want to plot them and show that plot in a manuscript. However, these numbers represent some private information and hence I don'...
2
votes
2answers
74 views

What is the appropriate data to display with linear regression?

What should be included on a graph with a linear model with a significant p-value? I see a lot of different regression graphs displaying everything from Pearson correlations to the linear model ...
0
votes
2answers
448 views

log transformation for geom_histogram and stat_function

I am playing around with lognormally distributed data, and I would like to visualize it both on the original and log scale with ggplot ...
0
votes
1answer
44 views

Comparing multiple lm results created in ggplot2 [closed]

I have the following example plot: Created via: ...
2
votes
1answer
105 views

Can I plot a beta distributed model with percentage rather than proportion? [closed]

I am analyzing a response variable (herbivory) which is a proportion, so I am using betareg function from the betareg package. The structure is similar to the GasolineYield dataset, so using it as ...
1
vote
1answer
597 views

How to add horizontal lines to a ggplot2 grouped barplot [closed]

I have created a grouped barplot with ggplot2 consisting of 4 groups (x-axis) with each 4 subgroups (bars). I now want to add a horizontal line (representing a threshold) similar to this. However, I ...
0
votes
1answer
30 views

What type of graphic will be suitable for 3 continuous vs 1 categorical variable [closed]

I want to create a graphic to explore relationship between 3 continuous and 1 categorical variable. I have 2 different examples I want to investigate. 1- the numeric variables are num of bedrooms ...
0
votes
1answer
44 views

What is the best way to reperesent this data (R)?

I am trying to show the correlations between life expectancy age and state pension age for men and women, per country. I have the following data here (working example): ...
0
votes
2answers
83 views

normalize/standardize data

I hope someone here can point me on the right direction. I have the following dataset. I have fish adult and juvenile data that I want to compare side by side, however, the juvenile fish numbers are ...
3
votes
1answer
519 views

How to construct a scatterplot with regression line that adjusts for other covariates?

I am attempting to produce a scatterplot with a regression line whose intercept & slope are adjusted to account for another covariate in the model. (I understand that the data points don't change, ...
2
votes
0answers
48 views

How can I add subscript in graph titles? I tried a code and it ran well for the first time however, its giving me an error. Any help is appreciated! [closed]

I tried this code and it ran well for the first time however, its giving me an error. Any help is appreciated! ...
-2
votes
1answer
34 views

Same size for multiple plots on different pages [closed]

Here is a MWE: ...
0
votes
1answer
4k views

Getting equation for lm/ggplot geom smooth with multiple levels [closed]

I'm trying to get equations for slope intercept for an lm with a three level categorical variable and a continuous covariate. Essentially I have plotted these using ggplot and in the legend I would ...
0
votes
1answer
386 views

Supply and Demand Graphs in R [closed]

Does anyone know of any R package that can make visuals for economics like the classic supply and demand graph? Obviously I googled this and found a package called "reconPlots" but I believe it's ...
4
votes
1answer
120 views

How to plot data to visualize variance of lower cluster if there is >1

I have the following data: ...
1
vote
1answer
54 views

Relationship between a categorical variable and a Bernoulli variable in R

I would like to answer the following question: What is the relationship between race and the likelihood of filing a state claim? Race is a categorical variable but since the response (...
0
votes
1answer
1k views

R calculate log-rank p-value of survival curve at specific time [closed]

I am using survfit object from package survminer to draw a survival curve in ggplot. Now I am trying to understand how I can use ...
0
votes
1answer
656 views

differences between emmeans and ggplot2

I have the following mixed model ...
2
votes
1answer
900 views

how do I plot interactions with continuous and categorical predictors in mixed models?

I'm very unsure how to plot mixed-level data consisting of a mixture of categorical and continuous predictors, so any help would be appreciated. This is the data ...
1
vote
0answers
17 views

plots to show whether the observed data is contained within a distribution

library(dplyr) library(ggplot2) df <- data.frame(year = 1980:2014, y = rnorm(35)) For each year, I have a model that predicts ~5000 values of ...

1
2 3 4 5