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.

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

extract color gived value from ggplot legend [migrated]

Given a numerical value Im trying to find the corresponding color in a ggplot legend; essentially the legend in reverse. I will try a simplified motivating example: I have some x-y data ...
1
vote
1answer
22 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 ...
1
vote
0answers
10 views

nls fit works but fails inside geom_smooth [migrated]

I want to use ggplot to fit an nls function to some data. The nls function is working well when used outside of geom_smooth() but inside it fails. Code: ...
5
votes
2answers
42 views

Explanation of centralityPlot in qgraph

I am using this code to get a centralityPlot. ...
1
vote
0answers
14 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 ...
1
vote
1answer
38 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
62 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
35 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
0answers
16 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
54 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
149 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
31 views

Comparing multiple lm results created in ggplot2 [closed]

I have the following example plot: Created via: ...
1
vote
1answer
67 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
100 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
29 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
41 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
0answers
35 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
2answers
71 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
310 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
58 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
42 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
33 views

Same size for multiple plots on different pages [closed]

Here is a MWE: ...
0
votes
1answer
2k 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
141 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
108 views

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

I have the following data: ...
1
vote
1answer
47 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
721 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
398 views

differences between emmeans and ggplot2

I have the following mixed model ...
2
votes
1answer
706 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 ...
0
votes
1answer
86 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
104 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
38 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
77 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
196 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
91 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
574 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
391 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
1k 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
816 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
45 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: ...
4
votes
3answers
2k 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
775 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
76 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
102 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
2k 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
456 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
58 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
2k 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 ...