ggplot2 is an actively maintained open-source chart-drawing library for R, written by Hadley Wickham, based upon the principles of "Grammar of Graphics". It partially replaces R's basic plot and the lattice package, while providing a clean, powerful, orthogonal and fun API.
-1
votes
1answer
41 views
ggplot2 figure margins in LaTeX Beamer via Knitr
I am currently playing with R and LaTeX via Knitr.
Trying to do a very simple slide deck with beamer, I run into a little issue. When I use the \includegraphics method to insert an image, it nicely ...
0
votes
0answers
32 views
Spacing between boxplots in ggplot2
I have been working with ggplot2 a lot over the past few weeks and was wondering if anyone could help me solve this problem I am having.
When I plot my boxplot my boxes are touching each other. I ...
-1
votes
1answer
23 views
Annotate ggplot error bar
I have been using R just for past 3 days and have got most of the code below through research which I have adapted to suit my needs. It works perfectly well. I want to be able to label/annotate ...
1
vote
1answer
32 views
stacked bar graph with log conversion of data or axis R
I'm trying to create a horizontal stacked bar chart to visualize the transition between the best performing models over a range of values. The point I'm having trouble with is that I would like my ...
2
votes
1answer
30 views
how to specify color of lines and points in ecdf ggplot2
I have a set of data that is tough to visualize, but I think an ECDF with a couple of points and lines added to it will do the trick. I am able to plot things the way that I want; my problem is ...
0
votes
1answer
25 views
how to draw arrow in ggplot2 with annotation
I am creating a ggplot chart where I need to put some annotation. I can do that but the text is not really pointing exactly the date that I like annotate. Is there a way to draw an arrow to axix where ...
5
votes
1answer
39 views
Drawing a plot to represent successive separation into categories (R, ggplot2)
This is a question both about best practices for visual representation of data and about how to draw plots in R/ggplot2.
I am trying to find a way to graphically represent the story told here:
...
-4
votes
0answers
38 views
Create a new plot with ggplot2 without deleting the old one [closed]
I'd like to know is there a way to create a new plot using ggplot2 without redrawing the old one, that I already have on screen.
1
vote
0answers
63 views
Create heatmap with distribution of attribute values in R (not density heatmap)
Some of you might have seen Beyond "Soda, Pop, or Coke". I am facing a similar problem and would like to create a plot like that. In my case, I have a very large number of geo-coded observations (over ...
1
vote
2answers
45 views
Adding R^2 on graph with facets
I am plotting geom_points on multiple facets and would like to annotate R^2 on each facet (preferably on the facet_label rather on the graph.) I have found some code here which will give me the R^2 ...
0
votes
1answer
39 views
Overlaying many mutlple rectangular plots or area plots (facing limits on alpha aka transparency)
Ideally, I could find a way to do this with area plots, but the example will be with rectangles. The issue is that alpha does not seem to be doing it's job. There might be a completely different ...
0
votes
2answers
62 views
Why does this R ggplot2 code bring up a blank display device?
While SO is not usually used for help with bugs, this one shows particularly simple and particularly annoying behavior. If you are a ggplot2 user, you can reproduce it in 10 seconds or less.
As this ...
0
votes
1answer
46 views
R - aggregate mean (generated in a loop) not appearing in graph
I have a few columns of data. I would like to find the mean for two different values for each time section by user. Then I would like to graph accordingly. There should only be one value for metricA ...
4
votes
1answer
54 views
ggplot2: Logistic Regression - plot probabilities and regression line
I have a data.frame containing a continuous predictor and a dichotomous response variable.
> head(df)
position response
1 0 1
2 3 1
3 -4 0
4 -1 ...
0
votes
0answers
35 views
Unwanted bold-face while putting multiple ggplot charts in the same file
I don't know if you have seen some unwanted bold-face font like picture below:
As you see the third line is bold-faced, while the others are not. This happens to me when I try to use ggplot() with ...
0
votes
1answer
24 views
ggplot2 geom_density limits
How can I remove the lines at the end of the limits in calls to geom_density?
Here is an example:
library(ggplot2)
set.seed(1234)
dfGamma = data.frame(nu75 = rgamma(100, 0.75),
nu1 = ...
0
votes
0answers
25 views
R ggplot2 stat_density2d fatal error
The function stat_density2d() in the package ggplot2 in R is causing a fatal error for me that crashes R. For example:
> library("ggplot2")
> n <- 15
> d <- data.frame(x=1:n+0.5, ...
1
vote
1answer
53 views
Fit decision boundary to logistic regression model in R
I'm struggling to plot a decision boundary in R using ggplot.
I have 2 variables (exam scores) and a binary classification whether a student was admitted to school or not. The data looks like below: ...
2
votes
0answers
33 views
Vary the fill scale when using facet_wrap and geom_tile together
When using function geom_tile and facet_wrap together in ggplot2, how to set different limits of the aesthetic fill, as the option scales which can be set to be free/free_y/free_x in facet_wrap?
The ...
0
votes
1answer
47 views
Change plot dimensions in ggplot2
I want to create a single pdf file and put several plots in it using package ggplot2. However I need to reduce the width of one specific plot, among all. Here is the code:
invisible(pdf("foo.pdf"))
...
0
votes
1answer
26 views
Using plotmath in ggplot2 with percent sign (%)
I would like to use Greek characters, Latin characters and the percent sign in the facet labels of a ggplot2 bar chart. Greek characters can be done with 'facet_grid(.~variable, ...
-1
votes
1answer
39 views
Order y-axis of ggplot by another factor (not alphabetically) R
I've read a lot of Q&As on sorting the y-axis of a heatmap made in ggplot2 and thus feel bad writing yet another, but I cannot seem to achieve what I desire. (This probably is because I am new to ...
0
votes
1answer
24 views
Identify location of specific individual(s) in ggplot geom_density facet_grid
I have 10 graphs produced using geom_density/facet_grid. Five of these have the same individual. Is it possible to indicate in the graph where the individual is for each facet? I thought of using ...
0
votes
1answer
23 views
Selecting colours for vline, such that they match the colour of lines produced with geom_line()
Let's say I'm plotting two densities from the diamonds dataset:
d_1 <- subset(diamonds, color %in% c("D", "E"))
ggplot(data = d_1, aes(x = price,colour=color)) + geom_density() +
...
5
votes
1answer
92 views
How to create 4x4 scatter plot using GGPLOT Facet
I have data frame like this:
library(ggplot2)
d.405 <- data.frame(abs(rnorm(30)),abs(rnorm(30)),abs(rnorm(30)),abs(rnorm(30)),type="405")
d.409 <- ...
1
vote
2answers
40 views
adding geom_text to ggfluctuation
Hi I am writing an R function to generate a fluctuation plot using ggplot2
fluctuation <- function(filename)
x=read.table(filename,sep=",")
mydata=melt(x)$value
...
0
votes
1answer
26 views
setting black/grey color scheme for ggplot2?
How can I set a black/grey/dark color scheme for ggplot2 (analogous to "theme_bw") for ggplot2, without manually specifying the color? i.e. have something like:
ggplot(mtcars) + ...
1
vote
1answer
39 views
How to create shaded regions following a rule across multiple facets
There are a few previous posts on how to make shaded regions in ggplot2 using geom_rect() but none of them help to create those shaded regions programmatically across facets. A good answer to my ...
1
vote
1answer
36 views
R ggplot bar chart
Consider the following code:
d <- data.frame(y = sample(LETTERS[1:8]), x = c(-1.6,-1.4,-1.2,0,0,1.2,1.3,1.4), stringsAsFactors = FALSE)
ggplot(d, aes(y=x, x=y)) + geom_bar() + coord_flip()
Can ...
0
votes
0answers
50 views
How to add labels to different time series in a ggplot [duplicate]
How can I add the labels "S&P 500", "Sotheby", and "Indpro" to my ggplot, so that they appear in the graph and in the legend?
g.gspc = ggplot(data = dfm_norm) +
geom_line(aes(x = Date, y = ...