Displaying 20 results from an estimated 31 matches for "coord_cartesian".
2023 Aug 02
2
Choosing colours for lines in ggplot2
...;#CC79A7") ## this is the colour-blind palette
set.seed(020823)
df<-as.data.frame(cbind(rep(1980:1991,2),c(10*runif(12),10*runif(12)),c(rep(1,12),rep(2,12))))
colnames(df)<-c("Year","Flow","Stat")
df
ggplot(df,aes(Year,Flow,group=Stat,colour=Stat))+
coord_cartesian(ylim = c(0, 10)) +
geom_line()+
geom_point()
## this works
## BUT:
## code 2
col.2<-cb8[4:5]
ggplot(df,aes(Year,Flow,group=Stat,colour=Stat))+
coord_cartesian(ylim = c(0, 10)) +
geom_line()+
geom_point()+
scale_color_manual(values =cb8[4:5])+
theme_bw()
## this gives error...
2009 Apr 25
2
Changing gird marks in ggplot2
Hi,
When I zoom into a graph created in ggplot2 with the
coord_cartesian(ylim=c(0,5)) option, I have no values labelled on my y-axis.
For this graph ggplot2 only puts labels the y-axis at intervals of 10 (i.e.
0, 10, 20, ...). However, the major portion of the graph I am interested in
is located between the values of 0 and 5 on the y-axis (thus why I am
zoooming). How c...
2008 May 12
1
Converting qqplot2 qplot() to grammar?
...ng the same way as
the qplot above:
ggplot(data = somdf, mapping = aes(x = pixX, y = pixY)) +
layer(data = somdf, geom = "tile", fill=rgb) +
scale_y_continuous(name=" ",breaks=" ") +
scale_x_continuous(name=" ",breaks=" ") +
scale_fill_identity() +
coord_cartesian() +
opts(aspect.ratio = .75) +
facet_grid(unitX ~ unitY,margins=FALSE)
The result is a plot where all tiles are filled with grey50, and not the
data values. I've also tried this variation with the same results:
ggplot(data = somdf, mapping = aes(x = pixX, y = pixY)) +
geom_tile(data = somdf,...
2013 Jan 24
1
Insert segment only on particular facets in ggplot
...me,y=data,colour=group1))+facet_wrap(~id,ncol=1)+theme_bw()
p1 <- p1 + xlab("Julian Day
(2008-2009)")+ylab(expression(Temperature~(degree*C)))+ element_blank()+
theme(
legend.position="right",
legend.direction="vertical",
legend.title = element_blank())
+coord_cartesian(xlim=c(250,550))+coord_cartesian(ylim=c(0,40))+scale_x_continuous(breaks=c(250,300,350,400,450,500,550),labels=c("250","300","350","34","84","134","184"))
p1
### This is how it should look like (though shows annotations for all...
2011 Nov 15
2
break error bars in ggplot2
Hello,
i use ggplot to plot some measures including CIs as horizontal errorbars. I get an error when the scale limits are narrower than the boundaries of the error bar and hence the CIs are not plotted.
library(ggplot2)
df <- data.frame(resp=c(1,2), k=c(1,2), se=c(1,2))
ggplot(df, aes(resp,y=k)) + geom_point() + geom_errorbarh(aes(xmax = resp + se, xmin = resp - se)) +
2010 Jun 24
1
Displaying additional values on the Y-axis ggplot2
...fg0 <- ggplot(aes(x=Grade,y=Math,colour=RiskStatic45678),data=math.f)
mfg1 <- mfg0 + geom_smooth(method="lm", formula=y ~ ns(x,2),size=1) +
geom_smooth(aes(y=nalt.math,color="NALT"),size=1,data=nalt) +
scale_colour_brewer("Risk Status", pal="Set1") + coord_cartesian(ylim =
c(175, 245))
mfg1
And when I specify that, the only value that shows up on the Y-axis is a
'200'. How can I manually specify that I want 180, 200, 220, and 240 to
show up? Also please cc me on the email as I am a digest subscriber.
Chris
2011 Feb 13
1
Changes titles in ggplot2 plot
Dear Colleagues,
In the following simple ggplot2 code:
--------------------------------
m <- ggplot(d.fig, aes(time, prob))
m + stat_summary(fun.data = "median_hilow", conf.int = .95, geom =
"smooth") + facet_wrap(~ Cohort, nrow=1) + coord_cartesian(ylim = c(0,
.03))
--------------------------------
Is there a way to replace the y-axis label from "prob" to "Predicted
Probability" and replace the x-axis label from "time" to "Time
Elapsed"?
Many thanks.
Best,
Shige
2011 Mar 29
1
ggplot2: scale_y_log10() with geom_histogram
Dear ggplot2 users,
is there an easy/elegant way to suppress zero count bars in histograms with
logarithmic y axis ?
One (made up) example would be
qplot(exp(rnorm(1000))) + geom_histogram(colour = "cornsilk", fill =
"darkblue") + scale_x_sqrt() + scale_y_log10()
Thanks!
Markus
[[alternative HTML version deleted]]
2011 Apr 22
1
ggplot
...plot( (subsetxx ) )+
geom_point(aes(x,y,colour=cut(Powermap,c(0,-1,-10,-20,-30,-40,-50,-60,-70,-80,-90,-100,-110))))+
geom_text(aes(x,y,color=cut(Powermap, c(0,-1,-10,-20,-30,-40,-50,-60,-70,-80,-90,-100,-110)), label=round(Powermap,3)),vjust=1,legend=FALSE)+labs(colour="Powermap")+
coord_cartesian(xlim = c(1, dimx),ylim = c(1, dimy))
2013 Jan 18
1
ggplot zoomin
Dear All,
I am plotting a graph in ggplot, I would like to magnify the values between 0-1 without losing data in the higher range. How can I do that? neither scale_y_continous nor coord_cartesian works.
Thank you
?zg?l
Universit? Libre de Bruxelles
2010 Nov 02
5
Question about ggplot2
Dear All,
I am trying to graph a simple scatter plot where the x axis is year
and the y axis is a percentage (percentage of infant death). Instead
of plotting the raw data, I want to plot summary statistics such as
mean and median. Here is the problem: the value range of y is between
0 and 1, but since infant death is a rare event, the mean and median
is very low (something like 5%), which shows
2009 Apr 27
3
Formatting numbers
...er Desjardins" <cddesjardins at gmail.com>,
> <r-help at r-project.org>
> Message-ID:
> <2E9C414912813E4EB981326983E0A10406653ACE at inboexch.inbo.be>
> Content-Type: text/plain; charset="us-ascii"
>
> Dear Chris,
>
> Changing
>
> coord_cartesian(ylim = c(0, 5))
>
> into
>
> coord_cartesian() + scale_y_continuous(limits = c(0, 5))
>
> That should solve your problem.
>
> HTH,
>
> Thierry
>
> ------------------------------------------------------------------------
> ----
> ir. Thierry Onkelinx
>...
2014 Jan 30
2
objecto ggplot
...hacer mi trabajo, algo similar a esto, pero adaptado a mi regiĆ³n.
Si te fijas en las lineas 141-161, esta esto:
## Convert the base map into a ggplot object
## All added Cartesian coordinates to enable more geom options later on
map.ggmap <- ggmap(map.base, extend = "panel") + coord_cartesian()
## Display a message
cat("Creating a ggplot object ...\n")
## Various display settings for the ggplot object
main.plot <- map.ggmap +
## Create a density plot
## based on the ggmap's crime data example
stat_density2d(aes(x = longitude,...
2017 Aug 05
2
Nested for loop
...;); require("scales")}
small.sample.dat <- schnabel.comp
small.sample <- ggplot(data = small.sample.dat,
mapping = aes(x = sample, y = pop.estimate)) +
geom_point(size = 2) +
geom_line() +
geom_hline(yintercept = N, col = "red", lwd = 1) +
coord_cartesian(xlim = c(0:100), ylim = c(300:500)) +
scale_x_continuous(breaks = pretty_breaks(11)) +
scale_y_continuous(breaks = pretty_breaks(11)) +
labs(x = "\nSample", y = "Population estimate\n",
title = "Sample sizes are between 5% and 15%\nof the population") +...
2010 Apr 19
2
plotting RR, 95% CI as table and figure in same plot
Hi all--
I am in the process of helping colleagues write up a ms in which we fit
zero-inflated Poisson models. I would prefer plotting the rate ratios
and 95% CI (as I've found Gelman and others convincing about plotting
tables...), but our journals usually like the numbers themselves.
Thus, I'm looking at a recent JAMA article in which both numbers and
dotplot of RR and 95% CI are
2012 Mar 16
1
ggplot axis limit
Hi,
This is probably an easy one, but I am new to ggplot2 and cannot find an
answer online.
I am bar plotting values of 10 groups. These values are all within a 90-100
range, so I would like leave out the area of the bars below 90. If I say
"graph + scale_y_continuous(limit=c(90, 100))", it does limit the axis but
the bars disappear completely. Any solution here?
Thanks a lot!
2013 Mar 15
0
ggplot2, arrows and polar coordinates
...--------------------------------------------------------------------
# Example adapted from the help page of "geom_segment"
library(ggplot2)
library(grid)
d <- data.frame(x1=-135.3, x2=-158.3, y1=37.2, y2=45.2)
p <- ggplot(seals, aes(x = long, y = lat))
p1 <-
ggplot() +
coord_cartesian() +
geom_rect(data=d, mapping=aes(xmin=x1, xmax=x2, ymin=y1, ymax=y2),
fill="red", color="red", alpha=0.5) +
geom_segment(data=seals, aes(x = long, y = lat, xend = long +
delta_long, yend = lat + delta_lat), arrow = arrow(length = unit(0.2,"cm")))
p2 <-...
2011 Aug 04
1
Plotting just a portion of a smoother graph in ggplot2
Hi,
I am using ggplot2 to with the following code:
gmathk2 <-
qplot(time,math,colour=Kids,data=kids.ach.lm.k5,geom="smooth",method="lm",formula=y~ns(x,1))
+ opts(title="Smoother Plot: Math K-5") + xlab("Time") + ylab("Math") +
scale_colour_brewer(pal="Set1"); gmathk2
This plots all the smoother for all the x values. What I'd like
2017 Aug 06
0
Nested for loop
...> small.sample.dat <- schnabel.comp
>
> small.sample <- ggplot(data = small.sample.dat,
> mapping = aes(x = sample, y = pop.estimate)) +
> geom_point(size = 2) +
> geom_line() +
> geom_hline(yintercept = N, col = "red", lwd = 1) +
> coord_cartesian(xlim = c(0:100), ylim = c(300:500)) +
> scale_x_continuous(breaks = pretty_breaks(11)) +
> scale_y_continuous(breaks = pretty_breaks(11)) +
> labs(x = "\nSample", y = "Population estimate\n",
> title = "Sample sizes are between 5% and 15%\nof the popula...
2023 Dec 14
0
R-help Digest, Vol 250, Issue 13
...help at r-project.org>, Ben Bolker <bbolker at gmail.com>
Subject: Re: [R] ggplot2: Get the regression line with 95% confidence
bands
Message-ID: <352cddfd-6db4-4715-bad1-2f5690d8dc29 at atsu.edu>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
coord_cartesian also seems to work for y, and including the breaks = .
How about:
df=data.frame(year= c(2012,2015,2018,2022),
score=c(495,493, 495, 474))
ggplot(df, aes(x = year, y = score)) +
geom_point() +
geom_smooth(method = "lm", formula = y ~ x) +
labs(title = "Standa...