Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ggplot2]

ggplot2 is an actively maintained open-source chart-drawing library for R, written by Hadley Wickham, based upon the principles of "The Grammar of Graphics". It partially replaces R's basic plot and the lattice package, while providing a clean, powerful, orthogonal and fun API.

0
votes
0answers
18 views

How to make a boxplot of two categorical variables using R? [on hold]

I want to make a boxplot of two categorical variables in R. Now both of the variables are stored as factor: Region w/ 9 levels Income06 w/ 26 levels To make a boxplot I need to somehow convert them ...
0
votes
0answers
12 views

Scatterplot with repeat values [migrated]

I am using ggplot to produce scatterplots. For some of the points, I have lots of rows in my data set with the exact same x and y values. Is there any way to have this situation reflected in the ...
0
votes
0answers
15 views

ggsave gives blank jpeg image [migrated]

I am trying to save my plots in my R script. I used the following context: ...
0
votes
0answers
17 views

Wilkinson dot plots

I came across a paper by Leland Wilkinson describing how to create dot plots, aptly named dot plots [1]. However, there were several things about the maths and algorithm that seemed wrong to me. I was ...
0
votes
0answers
26 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 ...
0
votes
0answers
50 views

R - Visualize results t-test in line plot

How can I visualize which values of each group are significantly different from each other in one plot? Consider the following mock example: I have data on variable ...
2
votes
0answers
36 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
41 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
32 views

Same size for multiple plots on different pages [closed]

Here is a MWE: ...
0
votes
1answer
343 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
48 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
89 views
1
vote
1answer
32 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
336 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
209 views

differences between emmeans and ggplot2

I have the following mixed model ...
2
votes
1answer
303 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
14 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 ...
0
votes
1answer
63 views

What are some left skewed models for curve fitting?

I am working on some data on thermal performances on my organism for my thesis. I came across the Ricker Model which is a right skewed curve as shown below. How can I modify it to become a left ...
2
votes
1answer
77 views

Efficient visualization of categorical data across multiple samples and categories in R

Assume a categorical variable (with states m, o and z) that can be measured for a set of 20 ...
1
vote
1answer
36 views

Extracting maximum (x,y) values and initial slope of non-linear fitted glm curves

I have plotted 8 curves using a log-link Gaussian model, y=ax exp(bx)+ϵ, for my data. I am not sure how to extract the maximum (x,y) from each of the fitted curves using the equation, of which I ...
0
votes
1answer
52 views

Variable with predictor name in Predict.rms

I would like to build regression models for a number of different exposure variables and show the results using ggplot.Predict of the ...
0
votes
0answers
22 views

Plotting a 3 predictor variable multiple regression model by marginalising for 2 of the predictors

I am working with a multiple regression model given by: Model5 <- lm(Patents After ECP~ No of co-pubs + ...
0
votes
0answers
139 views

Draw line through 2d density plot

have a large dataset of gene expression from ~10,000 patient samples (TCGA), and I'm plotting a predicted expression value (x) and the actual observed value (y) of a certain gene signature. For my ...
1
vote
0answers
59 views

Interpreting results of mvnorm.etest using energy package in R

I need to use functionalities of the energy package installed in R to give energy test of normality. So, as given in its documentation here https://cran.r-project....
5
votes
0answers
428 views

Why is a confidence ellipse based on multivariate-t tighter than one base on multivariate norm (R)

I want to draw a 95% confidence ellipse around my bivariate data. Using ggplot2::stat_ellipse() with type="t" (for a bivariate-t ...
1
vote
0answers
275 views

Logistic Curve displaying a straight line

I tried plotting the logistic curve in R using ggplot2 but am getting a straight line instead of the s-shaped curve. The image I received is displayed below below is my code ...
2
votes
1answer
871 views

Difficulty plotting a loess smooth: what causes these problems?

I'm very new at this and I don't actually understand the differences between the plotting methods, but loess seems to be giving me the most informative graphs, ...
1
vote
1answer
587 views

Visualization on Cluster for Mixed Data

So, i'm working with fuzzy clustering for Mixed data. Then i want to do Visualization for clustering result. Here is my data ...
2
votes
0answers
40 views

Density on Worldmap based on Relative Frequency [closed]

I'm trying to plot a 2d density on a worldmap. The problem is most of my points are around the same coordinates. My current map looks like this: Code for map: ...
3
votes
3answers
1k views

How can I visualise a three way interaction between two continuous variables and one categorical variable?

I have a model in R that includes a significant three-way interaction between two continuous independent variables IVContinuousA, IVContinuousB, IVCategorical and one categorical variable (with two ...
6
votes
1answer
489 views

Investigate overdispersion in a plot for a poisson regression

I run a poisson regression by hand and now want to investigate plots whether overdispersion might be a problem or not. What should I plot against each other?
1
vote
1answer
57 views

ideas for presenting data from multiple conditions

I have some data from an experiment that has 7 variables that have two levels to generate the conditions for the experiment. Consequently there are 128 (2^7) different combinations of variables. I've ...
0
votes
0answers
92 views

Plotting the influence of the second factor after excluding the influence of the first factor [R, lm(), lmer()]

I am conducting regression analysis and multilevel modeling in R using lme4 package. I would like to plot the influence of ...
-1
votes
3answers
1k views

Plotting the results of linear regression model using ggplot2 - interpretation

I have only recently learnt how to undertake a regression analysis in R. I was wondering whether someone could help me in interpreting what my ggplot result shows below?
1
vote
0answers
354 views

ggplot2 GLMM poisson model for rates

I gave a question about plotting the results of a GLMM Poisson model with an offset term and two random effects: ...
2
votes
0answers
55 views

Plots that look like coral [closed]

This is a rather unorthodox question. I have data sets with demographic information about coral from 3 different data-collecting dives (height, diameter, whether or not there was bleaching, whether or ...
2
votes
3answers
1k views

What is the best way of graphical or visual representation of confusion matrix?

I have classified the 15 classes dataset using machine learning algorithms. I don't want to put confusion matrix table since it is 15x15 matrix, instead, I want to represent it in a graphical way, ...
1
vote
0answers
1k views

How to effectively visualize multiple frequency polygons in ggplot2?

I apologize if this is not the appropriate site for this question. I am asking here because my question is about data visualization. I am comparing 5 distributions in R. So, I tried using frequency ...
0
votes
1answer
850 views
1
vote
1answer
333 views

How to get two regression lines using qplot [closed]

I have this nice script to plot a regression line based on the regression equation, easy to use when you want visible results from multilevel regression analyes. This works fine for one line in one ...
4
votes
2answers
4k views

Visualizing a multilevel model (HLM) in ggplot2

I have longitudinal data on several countries, looking at GDP and CO2 Emissions. In ggplot2, it is easy to make the software do something HLM-ish by plotting relationships separately for every country:...
2
votes
0answers
87 views

Quantiles based on raw data or density

I've created violin plots of my data and included quantile lines. These were created with the geom_violin function from ggplot2 ...
1
vote
0answers
431 views

How to interpret three/four-way interactions(continous) in logistic regression model through plotting in R

There are four variables have significant interaction effects in my logistic regression model, but I still did not get good way to interpret it through R software.  There are some discussion on 3-way ...
4
votes
0answers
205 views

How to visualize models after multiple imputations by chained equations

I'm starting to prefer visualizations of my regression models as opposed to tabular output (OR's, beta-coefficients, 95%CIs). However, I struggle to find a good way to do this when I am undertaking ...
1
vote
0answers
956 views

When plotting PCA analysis with loadings on top, loading arrows come out way too short [duplicate]

I am trying to make a reasonable looking PCA analysis, where not only data are projected in two axis, but also the loadings of the data are projected on top of the data. Similar to the following ...
4
votes
0answers
691 views

Plotting (multilevel) multiple regression

Lets say I have some data like this: ...
1
vote
1answer
93 views

How to fit observed data by assuming an equation beforehand?

Consider the following equation: where, OPDV = speed difference between a vehicle and its lead vehicle in the same lane (delta x - L) = H = distance between the front center of vehicle and rear end ...
0
votes
1answer
6k views

R - Plot multiple regression line with confidence intervals with ggplot2 [closed]

Somewhat newbie question here. I'd like to use ggplot2 to plot my multiple regression model, but I ran into an error. I did some research on the forum before deciding to ask the community. I ...
0
votes
1answer
406 views

Problems with plotting exponential curve and data in the same plot when values are high

I am running exponential regression on my data, but when trying to plot the curve I get a Inf problem because the independent variable values seem to be too high. How can I solve this in order to be ...
3
votes
0answers
1k views

I am unable to use ggplot2 to produce any graphs [closed]

When I try to plot graphs using ggplot, the graph does not appear on screen (as it would, say, for qplot). Instead, one of a few things happens. A blank white screen appears, a screen containing the ...