Displaying 20 results from an estimated 10000 matches similar to: "ggplot2 question ..."
2010 Mar 12
1
simple plot in ggplot2, wrong error bars
I was wondering if anyone could help me with this, simple problem.
I am essentially following the example on Hadley's webpage
(http://had.co.nz/ggplot2/geom_errorbar.html), but it still doesn't make any
sense to me.
df <- data.frame(trt = factor(c("intact", "intact", "removed", "removed")),
coon = c(0.093, 0.06, 0.057, 0.09), group =
2010 Aug 04
2
ggplot2 barplot: extra markers in graph
Dear List,
(self-contained example + version info at the bottom)
I'm having trouble producing a barplot using the functions in ggplot2. When I use the position="dodge" option, the bars are plotted but also a number of spurious markers. More specifically, a number of black dots are plotted in the graph that should not be there. This behaviour is not seen when calling the same
2018 Jan 15
0
barplot that displays sums of values of 2 y colums grouped by different variables
It is not generally advisable to get too fancy with stat functions in
ggplot... things can easily get more complicated than ggplot is ready to
handle when it comes to calculations. It is better to create data that
corresponds directly to the graphical representations you are mapping
them to.
Read [1] for more on this philosophy.
[1] H. Wickham, Tidy Data, Journal of Statistical Software,
2013 Feb 03
1
ggplot2 plotting errorbars.
Hi,
i'm using this lines of code:
dodge <-position_dodge(width=0.9)
ggplot(dfm,aes(x = X,y = value)) +
geom_bar(aes(fill = variable), position=dodge, stat="identity") +
geom_errorbar(aes(ymin=value-er, ymax=value+er),width=0.25,
position=dodge,stat="identity")
to plot this data frame
X variable value er
1 A X4 58.74 9.44
2 B X4
2008 Jun 16
1
ggplot2: How to remove legend component for geom_errorbar() ?
Dear list (probably Hadley),
I'm trying to do a plot like the following, composed of bars and error
bars:
df <- data.frame(factor1=gl(2,5), factor2=gl(5,1), y=rnorm(10),
err=0.1)
ggplot(df, aes(x=factor1, y=y, fill=factor2)) +
geom_bar(position="dodge", stat="identity") +
geom_errorbar(aes(min=y-err, max=y+err), position="dodge",
width=0.1)
The
2012 Mar 12
1
ggplot2: coord_polar
Hello HelpeRs,
The last print statement in the code segment below results in :
Error in data$x[data$x == -Inf] <- range$x.range[1] :
replacement has length zero
R version 2.14.1 Patched (2011-12-23 r57982)
ggplot2: version 0.90
OS : Linux (64bit)
Any thoughts?
Many Thanks,
A.
## code segment starts here
df <- data.frame(
trt = factor(c(1, 1, 2, 2)),
resp = c(1, 5,
2012 Mar 12
1
Faceted bar plot shows wrong counts (ggplot2)
I have encountered a problem with faceted bar plots. I have tried to
create something like the example explained in the ggplot2 book (see pp.
126-128):
library(ggplot2)
mpg4 <- subset(mpg, manufacturer %in%
c("audi", "volkswagen", "jeep"))
mpg4$manufacturer <- as.character(mpg4$manufacturer)
mpg4$model <- as.character(mpg4$model)
base <-
2010 Dec 06
2
ggplot2: Controlling line width of panel borders
Dear R-users,
i encountered some problems when trying to adjust the line width of the
axes and stripes in a plot created with ggplot2.
I use the "barley" dataset of the lattice package to illustrate my problem:
library(ggplot2)
library(lattice)
barley[["SD"]] <- 5
limits <- aes(ymax=barley$yield + barley$SD,ymin=barley$yield - barley$SD)
p1 <-
2013 Oct 30
1
ggplot2 - how to get rid of bar boarder lines
Hello!
I am using ggplot2:
ggplot(myplotdata, aes(x=att_levels, y=WTP)) +
geom_bar(stat="identity",fill="dark orange",colour="black",
alpha = 1,position = "identity") +
geom_text(aes(label=WTP),colour="black",size=4,hjust=1.1,position='dodge') +
coord_flip() +
xlab("") +
2010 Sep 01
2
ggplot2 multiple group barchart
hi there.. i got a problem with ggplot2.
here my example:
library (ggplot2)
v1 <- c(1,2,3,3,4)
v2 <- c(4,3,1,1,9)
v3 <- c(3,5,7,2,9)
gender <- c("m","f","m","f","f")
d.data <- data.frame (v1, v2, v3, gender)
d.data
x <- names (d.data[1:3])
y <- mean (d.data[1:3])
pl <- ggplot (data=d.data, aes (x=x,y=y))
pl
2013 Oct 30
1
ggplot2 question: keeping the order as in the input data
Hello!
I am using ggplot2 (see the code below) to plot the data in 'myplotdata'.
The first column of 'myplotdata' is called "att.levels" and contains
strings; the second column is called "WTP" and contains numeric values.
Notice - I use 'coord.flip()'
The command aes(x=att_levels, y=WTP), if I understand correctly, sorts
things alphabetically based on
2007 Oct 14
1
ggplot2: ordering categorial data
Hello again,
everytime I think I got something to work, the next issue comes up...
I have the following data.frame, I want to visualize:
> data_rb
tld spam1 spam2 share
1 ca 826436 73452 0.0889
2 org 470550 25740 0.0547
3 de 156042 15531 0.0995
4 com 140753 7527 0.0535
5 edu 34845 2507 0.0719
6 net 12781 382 0.0299
7 ru 7648 18 0.0024
2012 Oct 19
2
Axis Breaks with ggplot2
R-help -
I'm trying to create axis breaks similar to this :
http://www.r-bloggers.com/wp-content/uploads/2010/08/bar-chart-natural-axis-split1.png
.
Is there a way to do this in R? Here's my code thus far:
structure(list(condition = structure(c(2L, 1L, 3L), .Label = c("con",
"exp", "unedit"), class = "factor"), trial.avg = c(4.04583333333333,
2018 Jan 15
5
barplot that displays sums of values of 2 y colums grouped by different variables
I am trying to create a barplot displaying the sums of 2 columns of data
grouped by a variable. the data is set up like this:
"city" "n" "y" <br>
mon 100 200 <br>
tor 209 300 <br>
edm 98 87 <br>
mon 20 76 <br>
tor 50 96 <br>
edm 62 27 <br>
the resulting plot should have city as the x-axis, 2 bars per city, 1
representing
2018 Jan 15
0
barplot that displays sums of values of 2 y colums grouped by different variables
https://stackoverflow.com/questions/25070547/ggplot-side-by-side-geom-bar
On Mon, Jan 15, 2018 at 9:39 PM, Kenneth Dyson <kenneth at kidscodejeunesse.org
> wrote:
> Hi Eric,
>
> Thanks for the detailed response.
> This is not exactly what I want to do but is close.
> I want 2 bars for each city, 1 with the sum for "yes" , the other, beside
> it, with the sum for
2009 Feb 18
1
ggplot2 Y axis labels
Hi all:
Using the example below, is there a way to add Y axis titles to each graphic instead of sharing the same title?
library(ggplot2)
RT = matrix(c(814, 500, 424, 394, 967, 574, 472, 446),4,2)
colnames(RT) = c('repetition','alternation')
rownames(RT) = c('7-yrs','11-yrs','15-yrs','21-yrs')
rt <- melt(RT)
names(rt) <- c("age",
2008 Apr 29
2
ggplot2: labels and breaks order does not match and I can't use scale_fill_identity
Hi,
I'm plotting a bar chart like this:
ggplot() +
geom_bar(data=res,aes(fill=f1,x=f2,y=y),stat="identity",position="dodge")
f1 contains quite a few levels and the plot is really quite difficult to
read when the order of bars on the graph and on the legend does not match.
This problem has been discussed recently here:
2017 Jun 27
0
ggplot2 geom_bar label justification
Hi,
I was trying to make a horizontal bar plot. The barplot works when the text
labels are of reasonable length, but not if some of them are slightly long.
I think the long ones get 'squeezed' by default before the plot is flipped
and keep the skew after the flip. Is there a way I can get around this?
In the code below, plot px looks just fine, but the labels get staggered in
plot py.
2023 Nov 24
1
ggplot adjust two y-axis
Hi,
Just find a scaling factor that would make the two sets of data comparable.
Here I divided the second row by 5 and did the same for the second axis.
Charles-?douard
F1 <- as.table(matrix(c(50,11,6,17,16,3,1,2237,611,403,240,280,0,0), 2,7))
barplot(F1, beside = TRUE, col = c("blue", "grey")) axis(2,
at=c(0,10,20,30,40,50,60, labels=c(0,10,20,30,40,50,60))) axis(4, at =
2010 Oct 06
2
ggplot2 Pareto plot (Barplot in decreasing frequency)
Hi all
I have a large dataframe with (among others) a categorical variable of 52
levels and would like to create a barplot with the bars ordered in
decreasing frequency of the levels. I belive it is referred to as a pareto
plot.
Consider a subset where I keep only the categorical variable in question.
# Example:
v1 = c("aa", "cc", "bb", "bb",