Displaying 20 results from an estimated 485 matches for "geom_point".
2010 Feb 14
2
Problems with boxplot in ggplot2:qplot
...; qplot(factor(month), balance, data = closed, geom = "boxplot", xlim =
> range(closed$month))
There were 13 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: Removed 1 rows containing missing values (stat_boxplot).
2: Removed 7 rows containing missing values (geom_point).
3: Removed 5 rows containing missing values (geom_point).
4: Removed 8 rows containing missing values (geom_point).
5: Removed 3 rows containing missing values (geom_point).
6: Removed 5 rows containing missing values (geom_point).
7: Removed 2 rows containing missing values (geom_point).
8: Remo...
2020 Oct 21
2
AES spesification
Dear
I use dataset , as called "mpg"
This is code
ggplot(data=mpg)+ geom_point(mapping = aes(x=displ, y=hwy, colour=year))
But I would like to see only "year of 1999" in this relationship between x
and y variables
How could I change the code in this direction?
I found the following code
library(dplyr)year_1999 <- filter(mpg, year=="1999")ggplot(year...
2011 Aug 15
1
ggplot in a function confusion!
Whats going on here?
df<-data.frame(x=1:10,y=1:10)
ggplot()+geom_point(data=df,aes(x=x,y=y)) ## this is the normal usage
right?
ggplot()+geom_point(data=df,aes(x=df[,1],y=df[,2])) ## but I can also feed
it column indices
ggplot()+geom_point(aes(x=df[,'x'],y=df[,'y'])) ## or column names.
## but if i wrap it in a function...
plot.func.one<-func...
2013 Apr 25
1
problem with geom_point in ggplot using a different column
I want to draw boxplot where the geom_points are displayed based on
"ERBB2.MUT" subset and they should be displayed in the right box (based
both on the "ERBB2.2064" field and "ERBB2_Status").
However, given my command I currently only see "red" points corresponding
to "MUT" subset in one str...
2010 Apr 07
1
ggplot2, density barplot and geom_point layer
...c(myDiamonds[["clarity"]])
# Calculate medians
medians <- ddply(
myDiamonds,
.(cut),
summarize,
med=median(clarity, na.rm=TRUE)
)
# Works
myPlot <- qplot(
factor(clarity),
data=myDiamonds,
fill=cut,
geom="bar",
position="dodge"
)
myPlot +
geom_point(
data=medians,
aes(x=med,shape=cut),
y=0,
size=2.5,
)
# Doesn't work - I want density rather than count
myPlot <-qplot(
factor(clarity),
y=..count../sum(..count..),
data=myDiamonds,
fill=cut,
geom="bar",
position="dodge"
)
myPlot +
geom_point(
da...
2012 Jan 16
1
ggplot- using geom_point and geom_line at the same time
Hi
I am plotting line chart using ggplot and want to use geom_line and
geom_point simultaneously.
I get the plot but now I have two legends. None of the legend is
representing the true values. I need the legend with shape and color both.
Thanks
> con = textConnection("inputs var1 var2 var3+ 100 10 5 2+ 1000 20 10 4+ 5000 30 15 8+ 10000 40 20 16+ 30000 50 25 32"...
2017 Jun 16
2
point size
...c values of the log10_P to the point size in the graph.
Your help highly appreciated,
Regards,
Greg
p <- ggplot(mydata, aes(x = X, y = log10_P)) +
theme_bw() +theme(panel.border=element_blank())
+ theme(legend.position="top", axis.text=element_text(size = 8))
(p1 <- p + geom_point(aes(color = Traits)
[[alternative HTML version deleted]]
2017 Aug 25
2
about multi-optimal points
...be as close as 1, v2 to be as
close as 0. Thanks very much.
DF
ID v1 v2 v3
1 0.8 0.1 0.7
2 0.85 0.3 0.6
3 0.9 0.21 0.7
4 0.95 0.22 0.8
5 0.9 0.3 0.7
6 0.8 0.4 0.76
7 0.9 0.3 0.77
...
fig1 = ggplot(data=DF, aes(x=v1,y=v2))+ geom_point()+ theme_bw()+
xlab('Variable 1')+ ylab('Variable 2')
print(fig1)
fig2 = ggplot(data=DF, aes(x=v1,y=v3)+ geom_point()+ theme_bw()+
xlab('Variable 1')+ ylab('Variable 3')
print(fig2)
[[alternative HTML version deleted]]
2017 Jun 16
0
point size
You could add size = log10_P to the aes() inside geom_point().
Untested code below.
See also http://ggplot2.tidyverse.org/reference/geom_point.html
ggplot(mydata, aes(x = X, y = log10_P)) +
theme_bw() +
theme(panel.border=element_blank(), legend.position="top",
axis.text=element_text(size = 8)) +
geom_point(aes(color = Traits, size = log...
2017 Aug 26
0
about multi-optimal points
...ints you can set the colour aesthetic.
The ID is numeric so ggplot applies a colour scale. If we cast ID to a
factor we get the appropriate colouring.
test_df <- data.frame(ID = 1:20, v1 = rnorm(20), v2 = rnorm(20), v3 =
rnorm(20))
ggplot(data=test_df, aes(x=v1,y=v2, colour = as.factor(ID))) +
geom_point()+ theme_bw()+
xlab('Variable 1')+ ylab('Variable 2')
How to choose a number of samples from the dataset you can use the subset
function to select by some variable:
sub_test_df1 <- subset(test_df, ID < 5)
ggplot(data=sub_test_df1, aes(x=v1,y=v2, colour = as.factor(ID))) +...
2011 Apr 03
1
another question on shapefiles and geom_point in ggplot2
...points
# Plot the shapefile and overlayed the points over it
p <- ggplot(manuel_merged, aes(long,lat,group=group)) +
geom_polygon(aes(data=manuel_merged,fill=Area_Influ)) +
geom_path(color="white") + theme_bw() # remove this if you don't want black
and white background
p + geom_point(data=manuel_points,aes(size=ACE,colour=ACE,group=NULL)) +
scale_size(name = "Número\nde\nespecies", breaks = c(2, 4, 6, 8, 10, 12, 14,
16, 18, 20)) +
scale_colour_gradientn(name = 'Número\nde\nespecies',
colours = rainbow(6), breaks = c(2, 4, 6, 8, 10, 12, 14, 16, 18, 20))+...
2011 Dec 23
1
ggplot2: behaviour with empty datasets
For example, prepare like this
> df.0 <- data.frame(x = 0, y = 0, note = "1")
> df.1 <- subset(df.0, note == "1")
> df.2 <- subset(df.0, note == "2")
Then a call to
> ggplot() + aes(x = x, y = y) +
> geom_point(data = df.1) + geom_point(data = df.2)
produces the error
> Error in eval(expr, envir, enclos) : object 'x' not found
And a call to
> ggplot(df.1, aes(x = x, y = y, shape = 4)) +
> geom_point() + geom_point(aes(shape = 1), df.2)
plots both a cross (shape = 4) and circle (shape =...
2010 Nov 04
5
ggplot output
Dear All,
I have this script:
dat <- data.frame(Month = hstat$Date,C_avg = hstat$C.avg,C_stdev =
hstat$C.stdev)
ggplot(data = dat, aes(x = Month, y = C_avg, ymin = C_avg - C_stdev, ymax =
C_avg + C_stdev)) +
geom_point() +
geom_line() +
geom_errorbar()
dat <- data.frame(Month = hstat$Date,K_avg = hstat$K.avg,K_stdev =
hstat$K.stdev)
ggplot(data = dat, aes(x = Month, y = K_avg, ymin = K_avg - K_stdev, ymax =
K_avg + K_stdev)) +
geom_point() +
geom_line() +
geom_errorbar()
dat <- data.frame(Mo...
2023 Oct 30
1
Missing shapes in legend with scale_shape_manual
...115 FALSE FALSE
5 2023-10-13 08:44 136 FALSE TRUE
6 2023-10-12 08:55 122 FALSE TRUE
7 2023-10-11 07:55 150 TRUE TRUE
>
This gets me most of the way to what I want:
ggplot(data = b2, aes(x = Date, y = bg)) +
geom_line() +
geom_point(data = filter(b2, missed_meds),
shape = 20,
size = 3) +
geom_point(data = filter(b2, no_exercise),
shape = 4,
size = 3) +
geom_point(aes(x = Date, y = bg, shape = missed_meds),
alpha = 0) + #Invisible point layer for...
2009 Jul 23
1
ggplot2 : commands on one line vs two lines.
...1L, 373872L,
71450L, 53338L, 5660L)), .Names = c("Name", "Pcode", "Area"),
class = "data.frame", row.names = c(NA,
-13L))
library(ggplot2)
p <- ggplot(provs, aes(x = 0, xend = Area, y = Pcode, yend = Pcode))
# commmand below is on one line
pa <- p + geom_point(aes(Area, Pcode)) + geom_segment() + xlab("Area")
pa
pa1 <- p + geom_point(aes(Area, Pcode)) + geom_segment()
+ xlab("Area")
# Error in +xlab("Area") : invalid argument to unary operator
# commmand below is on one line
pb <- p + geom_point(aes(Area...
2008 Sep 22
2
adding layers in ggplot2 (data and code included)
...1 4.443696
1 1 4.588243
2 1 4.650505
0 2 4.296608
1 2 4.826036
2 2 4.765386"),header=TRUE);
closeAllConnections();
I can form two plots, scatter and lines, as follows:
p <- ggplot(mydata, aes(x=Est, y=Tri))
p + geom_point(aes(colour=factor(Group),shape=factor(Group)))
and
p+ geom_smooth(aes(group=factor(Group),color=factor(Group)),method=lm,se=F).
However, I am unable to have the plots together.
I obtain the following error:
> p + geom_point(aes(colour=factor(Group),shape=factor(Group)))+geom_smooth(aes(grou...
2012 Jul 02
5
ggplot: dodge positions
...by two factors) and I want to overlay the original observations and the following code does almost what I want:
library(ggplot)
ddf <- data.frame(x=factor(rep(LETTERS[1:4], each=30)), y = runif(120,0,10), grp = factor(rep(rep(1:3, 10), 4)))
ggplot(ddf, aes(x, y, colour=grp)) + geom_boxplot() + geom_point()
Yet the position of the points and the position of the boxes on the x-axis is not the same. I would like that the points are shifted accordingly, such that they line up with the boxplots. I tried position_dodge:
ggplot(ddf, aes(x, y, colour=grp)) + geom_boxplot() + geom_point(aes(ymax=max(y)),...
2008 Sep 10
1
ggplot2: edge outlines on points
...le to find the MatLab equivalent of
"MarkerEdgeColor" so
I've been working on trying to overlay two plots of the same points,
one plotted with fills and the other plotted with edge outlines (here
is my conceptual code):
pfill <- ggplot(data=DF, aes(x=X, y=Y)) +
geom_point(aes(colour=TRT),size=4) +
scale_colour_grey(end=0.8) +
theme_bw
pedge <- ggplot(data=DF, aes(x=X, y=Y)) +
geom_point(aes(colour=TRT),size=4) +
scale_colour_grey(end=0.8) +
scale_shape(solid=FALSE) +
theme_bw
However,...
2023 May 12
2
Newbie: Controlling legends in graphs
...re's my attempts. You can see some of the things I've tried in the
commented out sections:
weights %>%
group_by(year(Date)) %>%
summarize(
m_K = mean(K, na.rm = TRUE),
m_J = mean(J, na.rm = TRUE),
) %>%
ggplot(aes(x = `year(Date)`)) +
geom_point(aes(y = m_K, color = "red")) +
geom_smooth(aes(y = m_K, color = "red")) +
geom_point(aes(y = m_J, color = "blue")) +
geom_smooth(aes(y = m_J, color = "blue")) +
guides(size = "legend",
shape = "legend")...
2008 Sep 25
1
ggplot: adding layer using different data, groups and also controlling appearance
...;, "A", "B", "B" ) )
bar <- data.frame ( x = 1:4 + 1 , y = 4:1 + 1, membership = rep ( "C", 4 ) )
# This works, and produces a sensible (unified!) legend:
foo.gg <- ggplot ( mapping = aes ( x = x, y = y , colour = membership ) )
foo.gg <- foo.gg + geom_point(data = foo)
foobar.gg <- foo.gg + geom_point ( data = bar ) # works fine, creates a unified scale showing "membership"
foobar.gg
# This does not work:
booboo.gg <- foo.gg + geom_point ( data = bar, colour = "black" ) # so far, so good, but...
booboo.gg # it will not l...