Displaying 20 results from an estimated 3000 matches similar to: "Legend issue with ggplot2"
2008 Feb 17
1
ggplot2: bug in geom_ribbon + log scale!?
Hi everyone, Hadley,
it seems there's a bug in geom_ribbon() when using it in a log-scaled plot:
d<-data.frame(x=c(1:20),y1=rnorm(20)+3,y2=rnorm(20)+5)
p<-ggplot()
p<-p+geom_ribbon(data=d,aes(x=d[["x"]],min=d[["y1"]],max=d[["y2"]]))
p<-p+geom_line(data=d,aes(x=d[["x"]],y=d[["y1"]]),colour="blue")
2007 Jul 25
1
Ggplot2 equivalent of axis and problem with log scale
Dear useRs,
Recently I've discorved ggplot2 and I must say that I really like it,
although the documentation still is a working in progress.
My first question: How can I change the position of the labels and the
text of the labels? With a basic plot I would use axis(2, at =
position.of.the.ticks, labels = text.at.the.ticks). Could someone
provide me with an example of how to do this with
2010 Sep 16
1
plotting time series using ggplots
Hi,
I would like to plot a bunch of tree ring width data (time series)
using ggplots, but I'm having trouble figuring out how to do it.
My data is in a data.frame, with years as rownames and a distinct tree
ring series in each column. So, something like this:
rwl<-matrix(rnorm(800), nrow = 100)
colnames(rwl) <- paste('V', 1:8, sep = '')
2010 May 30
2
geom_ribbon removes missing values
Hi everyone,
it looks like geom_ribbon removes missing values and plots a single
ribbon over the whole interval of x values. However, I'd rather want it
to act like geom_line, that is, interrupt the ribbon for the interval of
missing values and continue once there are new values. Here's an example:
library(ggplot2)
df <- data.frame(
date = seq(from = as.Date("2010-05-15"),
2012 Feb 16
2
Problem building up ggplot graph in a loop.
Folks,
I want to automate some graphing using ggplot.
Here is my code
graphChargeOffs2<-function(coffs) {
ggplot(coffs, aes(levels))
dataNames<-names(coffs)[!names(coffs) == "levels"]
for(i in dataNames) {
thisData<-coffs[[i]]
last_plot() + geom_line(aes(y = thisData, colour = i))
}
last_plot() + ylab("Total Chargeoffs")
}
coffs is a data.frame.
2023 Aug 12
1
geom_smooth
?s 05:17 de 12/08/2023, Thomas Subia via R-help escreveu:
> Colleagues,
>
> Here is my reproducible code for a graph using geom_smooth
> set.seed(55)
> scatter_data <- tibble(x_var = runif(100, min = 0, max = 25)
> ?????????????????????? ,y_var = log2(x_var) + rnorm(100))
>
> library(ggplot2)
> library(cowplot)
>
> ggplot(scatter_data,aes(x=x_var,y=y_var))+
2010 Oct 19
2
superpose.polygon, panel.polygon and their colors
Dear R-helpers,
the problem I'm facing today is to convince lattice to paint some areas
in gray.
The areas I would like to have in gray, are confidence bands
I've googled around in the mailing list archives and eventually find
some clues.
This link is my starting point
http://tolstoy.newcastle.edu.au/R/e2/help/07/04/15595.html
I'm reproducing here the code for your convenience
est
2009 Apr 23
1
ggplot2/aesthetic plotting advice
Consider the following situation:
we have quantified algal concentrations for
a variety of species using many samples at each
of three years. It seems to make sense to generate
a line plot (matplot-like), with each species plotted
as a separate line, with the points connected to emphasize
the temporal pattern.
The problem: lots of overlapping error bars.
The question: from both a
2023 Aug 12
2
geom_smooth
Colleagues,
Here is my reproducible code for a graph using geom_smooth
set.seed(55)
scatter_data <- tibble(x_var = runif(100, min = 0, max = 25)
?????????????????????? ,y_var = log2(x_var) + rnorm(100))
library(ggplot2)
library(cowplot)
ggplot(scatter_data,aes(x=x_var,y=y_var))+
? geom_point()+
? geom_smooth(se=TRUE,fill="blue",color="black",linetype="dashed")+
2007 Dec 03
3
ggplot2: Choosing colours
Dear useRs,
I'm trying to specify the colour of a factor with ggplot2. The example
below gets me close to what I want, but it's missing a legend.
Any ideas?
Thanks,
Thierry
library(ggplot2)
dataset <- data.frame(x = rnorm(40), y = runif(40), z = gl(4, 10, labels
= LETTERS[1:4]))
ggplot(data = dataset, aes(x = x, y = y, group = z)) + geom_point(colour
= c("red",
2011 Jan 06
1
Help spruce up a ggplot graph
Given the data structure below and the call to ggplot2, how can I increase the size of the axis scale points, the line weight, and the size of the legend?
ddata <-structure(list(year = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("2003", "2007"), class = "factor"),
area = structure(c(7L, 6L, 1L, 2L, 3L, 4L, 5L, 7L, 6L, 1L,
2017 Jun 30
0
Multiple "scale_color_manual" statements in one plot (ggplot2, flexible legend challenge)
Dear list,
I am facing an unusual situation where I need to create two sets of legends
based on the color mapping. Can't get exactly what I want and really
appreciate any advice from ggplot experts.
Let's say I have the first dataset "df1" that draws some points and based
on which a "loess" line with confidence interval is added. Then the second
dataset
2020 Oct 26
0
How to shade area between lines in ggplot2
Hi
Put fill outside aes
p+geom_ribbon(aes(ymin = slope_1*x + intercept_1 - 1/w[2],
ymax = slope_1*x + intercept_1 + 1/w[2]), fill = "blue", alpha=0.1)
The "hole" is because you have two levels of data (red and blue). To get rid
of this you should put new data in ribbon call.
Something like
newdat <- trainset
newdat$z <- factor(0)
p+geom_ribbon(data=newdat, aes(ymin =
2007 Jul 09
0
Problem with Sweave and pdf version 1.4
Dear useRs,
I'm trying to use ggplot2 in Sweave (R 2.5.1). The plots use the alpha
channel, so I need to use pdf version 1.4. Search the mailinglist
archive I found two solutions: \SweaveOpts{echo = FALSE,
pdf.version=1.4} and explicit writing to a pdf 1.4 file. The latter
works but the first doesn't. Probably I'm doing something wrong (see the
Rnw file below). The file tmp_tmp.pdf is
2007 Jul 18
1
Strange warning in summary.lm
Dear useRs,
Lately I noticed a strange warning in the summary of a lm-object. Any
idea what this warning is about? I'm using R 2.5.1 on Win XP pro.
> x <- rnorm(100)
> y <- rnorm(100)
> summary(lm(y~x))
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-1,77809 -0,68438 -0,04409 0,63891 2,30863
Coefficients:
Estimate Std.
2020 Oct 23
2
How to shade area between lines in ggplot2
Thank you, but this split the area into two and distorts the shape of
the plot. (compared to
```
p + geom_abline(slope = slope_1, intercept = intercept_1 - 1/w[2],
linetype = "dashed", col = "royalblue") +
geom_abline(slope = slope_1, intercept = intercept_1 + 1/w[2],
linetype = "dashed", col = "royalblue")
```
Why there
2020 Oct 23
0
How to shade area between lines in ggplot2
Hi
What about something like
p+geom_ribbon(aes(ymin = slope_1*x + intercept_1 - 1/w[2],
ymax = slope_1*x + intercept_1 + 1/w[2], fill = "grey70", alpha=0.1))
Cheers
Petr
> -----Original Message-----
> From: Luigi Marongiu <marongiu.luigi at gmail.com>
> Sent: Friday, October 23, 2020 11:11 AM
> To: PIKAL Petr <petr.pikal at precheza.cz>
> Cc: r-help
2020 Oct 23
2
How to shade area between lines in ggplot2
also from this site: https://plotly.com/ggplot2/geom_ribbon/
I get the answer is geom_ribbon but I am still missing something
```
#! plot
p = ggplot(data = trainset, aes(x=x, y=y, color=z)) +
geom_point() + scale_color_manual(values = c("red", "blue"))
# show support vectors
df_sv = trainset[svm_model$index, ]
p = p + geom_point(data = df_sv, aes(x=x, y=y),
2007 Feb 13
1
RE2: Suddenly "Subscript out of bounds"
If you tell me how to update R itself automatically, I will go for your
advice.
I am not aware of any method to do it...
Bye
Rick
"ONKELINX,
Thierry"
2010 Jun 07
1
Patch for legend.position={left,top,bottom} in ggplot2
Hi Hadley and everyone,
here's a patch for ggplot2 that fixes the behavior of
opts(legend.position={left,top,bottom}). If you try the following code
in an unmodified ggplot2
options(warn = -1)
suppressPackageStartupMessages(library("ggplot2"))
data <- data.frame(
x = c(1, 2, 3, 4, 5, 6),
y = c(2, 3, 4, 3, 4, 5),
colour = c(TRUE, TRUE, TRUE, FALSE, FALSE, FALSE))