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.

learn more… | top users | synonyms (1)

0
votes
1answer
32 views

Compare regression slopes of repeated measures linear regression

In my design, I have two groups of subjects and every subject is tested in four different conditions. So, I have a within-subject factor ('span_num', which ranges from 0 to 3) and a between-subject ...
0
votes
0answers
3 views

Create grid and color cells with average values of scatterplot using ggplot2 [migrated]

Given a numeric dataset $\{(x_i, y_i, z_i)\}_{i = 1}^N$, one can create a scatterplot by drawing a point $P_i = (x_i, y_i)$ for each $i = 1, \dots N$ and color each point with an intensity depending ...
0
votes
0answers
4 views

ggplot2: geom_polygon with no fill [migrated]

i hope, you dont need data for this problem, because i believe i am just making a stupid syntax error. The following code: ...
0
votes
0answers
4 views

R - emulate the default behavior of hist() with ggplot2 for bin width [migrated]

I'm trying to plot an histogram for one variable with ggplot2. Unfortunately, the default binwidth of ggplot2 leaves something to be desired: I've tried to play with ...
1
vote
1answer
134 views

Smoother lines for ggplot2

This question probably has a simple solution, still the thing is I've written a code to plot mortality in 2 different groups and that is, death in obese patients vs not obese. Now their are 2 groups ...
2
votes
1answer
36 views

How to plot a comparison of read counts in R

I have a bunch of genetic read counts for different several genes. Each gene is divided into two groups (0 and 1). What I want to do is make a vertical plot side by side of the 0 group and the 1 ...
1
vote
1answer
90 views

R scatterplot matrix with nonparametric density

I normally use MATLAB, or JMP but right now am working with R. I have ~150 dimensional data with a few hundred thousand rows. Some of the columns are non-informative, they only have one value. This ...
1
vote
0answers
54 views

Contradicting interaction significance with graphical visualisation in glmer

I'm investigating environmental effects (wind) on acoustic receiver detection probability for two types of transmitters using a binomial glmer. While my model analysis indicates that there's a ...
2
votes
1answer
132 views

How can I 'dodge' the position of geom_point in ggplot2?

I am using ggplot2 in R to make plots like the following ones: The errorbars overlap with each other which look really messy. How can I separate the errorbars for different indices? I have used ...
0
votes
0answers
13 views

Plot triple optimization boosting procedure

I am looking for a way to graph a triple optimization used in boosting. I did individual cross-validation on shrinkage, number of trees, and interaction depth and found the boundaries of interesting ...
0
votes
0answers
175 views

Q: plot glmm fixed and random effects (glmer in package lme4) using ggplot2

I am trying to visualize the results from a glmm that I ran with the lme4 package. ...
2
votes
2answers
108 views

How can I cluster data in a grid-like fashion and heat map the averages in R?

I have a data frame of 3 columns. The first one is the response variable the second and the third ones are some criteria. You can create your own example similar to mine, using this piece of code with ...
1
vote
2answers
64 views

What is the best way to automatically select sensible, comprehensible breakpoints?

ggplot2 seems to, by default, select very nice, comprehensible breaks for continuous data. I would like to plot the data according to one scale (logistic) by ...
5
votes
1answer
50 views

Parameter region for existence of solutions of equation

How does one plot the set S of parameter region of equations using r?. My problem is that I have one equation with 2 variables defined by $g(x,a,b) = 0$ and I want to plot the set of $(a,b)$ where the ...
0
votes
1answer
62 views

Can I Use a Dummy Variable in Quadratic form in lm() in R?

I'm trying to replicate models published in The Age-Productivity Gradient: Evidence from a Sample of F1 Drivers and am stumbling at first hurdle over a line "the baseline specification contains a ...
1
vote
2answers
31 views

T test with one group

I think it is a simple question, but I got many different results and now I am not sure which test to use. I have one group and 2 different scores (higher scores means higher either positive or ...
5
votes
1answer
132 views

Demonstrate difference in growth over time

Short version Is there a difference per treatment given time and this dataset? Or if the difference we're trying to demonstrate is important, what's the best method we have for teasing this out? ...
2
votes
1answer
250 views

R ggplot2/ezPlot: Plotting 3x3 RM ANOVA design per quantile of covariate with error bars

First of all, my data: http://www.pastebin.ca/2599202 (I hope this is not too inconvenient, because I fail creating good fitting example data) What I basically need, is a plot like: I plotted the ...
0
votes
0answers
68 views

comparing results of lmer using geom_area plots

I was wondering if somebody could help with trying to visualise some data. I have 11 groups of organisms and have related them to levels of a specific bacteria in water samples. I have a strong ...
1
vote
1answer
143 views

Learning curve shows decreasing accuracy

I'm working on a random forest classifier with 10-folds CV to aestimate the hyperparameter 'mtry' (chosen by maximizing AUROC). I decided to pre-split the training set in 8 samples equals in size ...
0
votes
1answer
830 views

Risk table for a Kaplan Meier plot in R

I need to make a Kaplan Meier plot with a risk table beneath it. Otherwise stated, I need a table of the number of subjects at risk at different time points aligned below the figure. I found a website ...
2
votes
1answer
126 views

Plot 3 density plots in the same graph, showing also standard deviation limits in each one

I have obtained from a paper next results: Variable 1: Mean=165, sd=15 Variable 2: Mean=149, sd=18 Variable 3: Mean=134, sd=25 I have simulated normal distributions using rnorm. This is the way ...
0
votes
1answer
690 views

In R, how do I fit a student-t distribution to a set of empirical data? [duplicate]

In R, I can fit a Probability Density Function to some empirical data using the following code: ...
1
vote
2answers
50 views

Plotting data from several files on one plot

I have more than one file of data from different experiments. For the sake of the argument here, let's say I have three files E1.txt, ...
0
votes
2answers
86 views

How to retrieve adjusted values for a predictor variable in a linear model in R

Using R and ggplot, I would like to plot my output variable with one of my predictor variables adjusted for the other variables in the model. (I'm asking this question here, because I don't actually ...
1
vote
0answers
26 views

Creating a ‘bounding polygon’ for a set of points (preferably with GGplot2) [duplicate]

In R, Lets say that I have a set of x and y points, how can I get a geom_polygon to encapsulate all points, ie, what is the best way to create a 'bounding' polygon ...
3
votes
2answers
146 views

Comparing weights versus time graphically using reshape, vioplot, and ggplot2

I have a group of 200 children who came to clinic at months 0, 1, 2, 3, 6, 9, and 12 this year. At each clinic visit the children were weighed. ...
1
vote
0answers
280 views

Creating summary tables / graphics in R for categorical data [closed]

I am trying to summarise data from a household survey and as such most of my data is categorical (factor) data. I was looking to summarise it with plots of frequencies of responses to certain ...
1
vote
0answers
109 views

How build smoothed curve of incidence rates using subject data? [closed]

I have a dataset with subjects ($\text{data}_0$). Each subject has a follow up time ($\text{fuy}$), an indicator for incidence ($\text{ind} = 0/1$) and a variable which indicates, for example, year of ...
6
votes
4answers
853 views

Boxplot equivalent for heavy-tailed distributions?

For approximately normally distributed data, boxplots are a great way to quickly visualize the median and spread of the data, as well as the presence of any outliers. However for more heavy-tailed ...
1
vote
1answer
87 views

Plotting the gap between two times

I have a (large) dataset where I know, for each observation, the departure and the arrival time of a worker (between 0 and 24, in decimal) : ...
0
votes
1answer
727 views

US heatmap using zipcodes

We are attempting to create a US heatmap using only zipcode and corresponding values using R. While there are a number of examples that use lat and long data for creating such maps, is there one that ...
1
vote
0answers
103 views

Is LOESS the appropriate way of visualizing my RT data?

I am conducting a Lexical Decision Task where my dependent random variable is Response Time (RT). My experimental design consists of 5 blocks of a 100 trials each. In each block, 50% of trials ...
3
votes
1answer
169 views

Graphical representation of cross-validation errors for regression

What are some good ways of presenting/comparing cross-validated RMSE errors for regression using various models, graphically via plots? As of now, I have been presenting the quantitative results in ...
8
votes
1answer
2k views

How does ggplot compute confidence intervals for regressions?

The R plotting package ggplot2 has an awesome function called stat_smooth for plotting a regression line (or curve) with the associated confidence band. However I am having a hard time figuring out ...
2
votes
2answers
304 views

Plotting a model in R

I have used the vglm() function from the VGAM package to obtain a Weibull model for some data. I would like to plot the curve that this model is represented by. How do I do this? Here's my input and ...
5
votes
1answer
926 views

How do I create and interpret an interaction plot in ggplot2?

I am trying to make an interaction plot for this set of data, but I want to make it with ggplot2. I am trying to predict VP using the predictors G and P, (these are columns in the dataset which I have ...
1
vote
3answers
862 views

How to compare dependent variables with different units using Grammar of Graphics paradigm?

My data analysis workflow is through R and ggplot2, in part because ggplot2 discourages me from making 'bad' (misleading, etc.) ...
10
votes
1answer
2k views

Getting different results when plotting 95% CI ellipses with ggplot or the ellipse package

I want to visualize the results of a clustering (produced with protoclust{protoclust}) by creating scater plots for each pair of variables used for classifying my ...
4
votes
1answer
428 views

Visualization of binned frequency distribution in R

I am trying to visually represent the distribution of last names in the US. Specifically, I am trying to show that the distribution is such that the most common names (say the top 50) are very common ...
6
votes
2answers
2k views

How to predict or extend regression lines in ggplot2?

I have a data frame that contains two time series: the dates and version numbers of Emacs and Firefox releases. Using one ggplot2 command it's easy to make a chart that uses loess (in a way that looks ...
5
votes
2answers
220 views

Temporal trend visualizations for regions

I try to reproduce a plot which I found in a publication (Mayor-Fernández et al 2012) showing unemployment rates across time for several regions. It combines a heatmap (?), a time series plot (lower ...
6
votes
0answers
368 views

Modeling a spline over time — design matrix and survey of approaches

A response variable y is a nonlinear function of a number of predictor variables X (in my real data the response is binomially distributed, but here I'm using a normally-distributed value for ...
2
votes
2answers
4k views

Plot a subset of categories on the x-axis in ggplot

everyone! I'm trying to plot pvalues of a test by categories (in this case, genetic loci). So, the x-axis contains gene names. I'm getting the plot to work, but the x-axis was very busy, so I am ...
18
votes
6answers
8k views

How to determine best cutoff point and its confidence interval using ROC curve in R?

I have the data of a test that could be used to distinguish normal and tumor cells. According to ROC curve it looks good for this purpose (area under curve is 0.9): My questions are: How to ...
6
votes
1answer
916 views

How to visualize both total counts of categories and proportions of subcategories in a plot?

Suppose I have samples drawn from categories A, B, C. Within those categories, I have subcategories d,e,f which are found in all 3 categories. I want to visualize how many samples I have form ...
13
votes
2answers
1k views

Are gridlines and grey backgrounds chartjunk and should they be used only on an exception basis?

It seems that most authorities agree that dark or otherwise prominent gridlines in plots are "chartjunk" by any reasonable definition and distract the viewer from the message in the main body of the ...
1
vote
1answer
1k views

Dropping unused levels in facets with ggplot2

Is it possible to drop levels that are not used in ggplot2s facets? This is my code: ...
1
vote
0answers
41 views

How to use ggplot to do the binned quantile plots(one type of scatter plot)? [duplicate]

Possible Duplicate: How to do a pretty scatter plot in R? How to use ggplot to do the binned quantile plots(one type of scatter plot)? Hi all, I have done scatter plot: plot(x, y). Now I ...
17
votes
2answers
4k views

How to draw neat polygons around scatterplot regions in ggplot2

How do I add a neat polygon around a group of points on a scatterplot? I am using ggplot2 but am disappointed with the results of geom_polygon. The dataset is over ...