Displaying 20 results from an estimated 4000 matches similar to: "ggplot2 example"
2009 Mar 11
1
Ggplot2: saving a grid with multiple plots
Hi all,
I have managed to create a figure on the screen with multiple plots in
it. Something like the example below. When I save that with ggsave(),
only the last plot gets saved (pPath in the example) instead of the
entire figure. Any suggestions how I can save this kind of figures
automated?
Thanks,
Thierry
library(ggplot2)
pPoint <- qplot(unemploy/pop, psavert, data=economics)
pPath
2013 Apr 14
1
Problem plotting continuous and discrete series in ggplot with facet
I have data that plots over time with four different variables. I would
like to combine them in one plot using facet_grid, where each variable gets
its own sub-plot. The following code resembles my data
require(ggplot2)
require(reshape2)
subm <- melt(economics, id='date', c('psavert','uempmed','unemploy'))
mcsm <- melt(data.frame(date=economics$date,
2009 Oct 06
1
ggplot2 applying a function based on facet
Look at the bottom of the message for my question
#here is a little function that I wrote
USGS <- function(input="discharge", days=7){
library(chron)
library(gsubfn)
#021973269 is the Waynesboro Gauge on the Savannah River Proper (SRS)
#02102908 is the Flat Creek Gauge (ftbrfcms)
#02133500 is the Drowning Creek (ftbrbmcm)
#02341800 is the Upatoi Creek Near Columbus (ftbn)
#02342500 is
2010 May 18
2
Function that is giving me a headache- any help appreciated (automatic read )
note: whole function is below- I am sure I am doing something silly.
when I use it like USGS(input="precipitation") it is choking on the
precip.1 <- subset(DF, precipitation!="NA")
b <- ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum)
DF.precip <- precip.1
DF.precip$precipitation <- b$.data
part, but runs fine outside of the function:
days=7
2011 Dec 23
1
simple ggplot2 question
Hello,
I am trying to make a plot using the code below. The plot is divided into two parts, using facet_grid. I would like the vertical axis (labelled 'place') to be different for each location (=part). So in the upper part, only places 'n' through 'z' are shown, while in the lower part, only places 'a' through 'm' are shown. I thought 'free_y'
2020 Nov 24
2
Cambiar nombre de topic en análisis LDA
Buenas tardes
Estoy haciendo un análisis LDA y me gustaría cambiar el nombre de los
topics a la hora de visualizarlos y en vez de que se llamen 1,2,3...darles
un nombre. ¿Es posible en este código?
lda22 <- LDA(reviews_dtm, k = 22, control = list(seed = 1234))
lda22 %>%
tidy() %>%
group_by(topic) %>%
top_n(10, beta) %>%
ungroup() %>%
mutate(term =
2009 Oct 06
2
ggplot cumsum refined question (?)
OK, so maybe last night was a little too much at one throw, so I have
reduced the data to two stations- one that has precipitation and one
that does not. This is going to be in the context of a larger data
set. I would like to be able to issue a ggplot command and have cum
sum just act on the facets (factors) to apply this.
library(chron)
library(ggplot2)
DF <- structure(list(date_time =
2010 Aug 24
1
drop unused levels in lattice dotplot axis?
Hi list, I have a data set - something like this
dfr <- data.frame(A=factor(letters[1:25]),B=runif(25), C=sample(LETTERS[1:4],25,replace=TRUE))
and I want to create a dotplot:
library(lattice)dotplot(A ~ B | C, data=dfr, scales=list(y=list(relation="free")))
but this puts uneven spaces along the y-axis in each panel. drop.unused.levels=TRUE will drop conditioning
2010 Sep 11
1
Setting scales for ggplot2 with facets
Faceting in ggplot2 seems to permit different scales for different
facets, but I fail
to see how one could control ylim and xlim ranges for each facet
separately.
For instance, I would like to set the ylim = c(0,10) for facet "A"
and ylim = c(42,102) for facet "B". Since the data is out of these
ranges,
setting facet_grid(factor ~ ., scales = "free_y") does not
2010 Jan 18
2
ggplot2 histogramm
Hi,
i get no success change the title of the "fill" (colour) legend and the
defintion of "levels". Have anybody a hint how i can do this.
df <-
data.frame(variable=sample(c("A","B","C"),1000,replace=T,prob=c(0.22,0.28,0.5)),group=gl(2,500))
p <- ggplot(df, aes(x = variable))
p + geom_histogram(aes(y= ..count.. /
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
2010 May 31
1
Can not save plot to png file correctly
You can save as png like this too:
library(ggplot2)
data=data.frame(
? X=sample(10,1000,replace=T)
? , Y=letters[1:10])
png("mypng.png")
qplot(X, data=data, geom='histogram') + facet_wrap( ~ Y)
dev.off()
?
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA
----- Original Message ----
> From: Peng Yu
2010 Apr 29
1
Sweave question
Hi:
I am using Sweave and texi2dvi to generate a LaTeX document but
can't find the way to hide the graphics while the R chunks are being
executed. I thought results=hide would do it but that't not the case.
If I do:
\begin{figure}[h]
<<figA=true,echo=F,fig=T,results=hide>>=
a < rnorm(1000)
plot(a)
@
\caption{Weekly estimates.}
\label{figure:ggplot1}
\end{figure}
The
2010 Feb 08
3
ggplot2 stacked line plot
Hi all,
I have been hunting around for hours trying to figure out how to
generate a stacked line chart using ggplot2. This type of chart can be
generated in excel 2007 by selecting: Chart type > Line > Stacked
line. I can generate a stacked area chart using the following code:
p <- ggplot2(~, aes(x = ~, y = ~, colour = Type)) +
geom_area(aes(position = 'stack', fill = Type))
2012 Mar 05
2
ggplot2
I just updated to R 2.14 with ggplot2 0.9 and am finding bugs.
> ggplot2 "GPL-2" "2.14.0"
This example is taken from pg 101 in the ggplot book.
> plot <- qplot(date, psavert, data = economics, geom = "line") +
> ylab("Personal savings rate") + geom_hline(xintercept = 0, colour =
> "grey50")'
> plot +
2009 Jul 24
1
ggplot question
In page http://had.co.nz/ggplot2/scale_date.html , there is a time series
plot for multiple variables at the bottom. i.e
qplot(date, value, data = em, geom = "line", group = variable) +
+ facet_grid(variable ~ ., scale = "free_y")
How can I make different color for different series?
Thanks
--
View this message in context:
2010 Feb 04
2
ggplot2 / time series with different scales
I am trying to plot this dataset using ggplot2:
df <- data.frame(
sid = c(rep('11',30),rep('22',30)),
time = rep(ISOdate(year = 2010, month = 1, day = 1:30),2),
sales = c(rnorm(30, 1000, 20),rnorm(30, 900, 10)),
price = c(rnorm(30, 2, 0.5),rnorm(30, 3,0.5))
)
Plotting just the sales can be done easily:
ggplot(data=df, aes(x=time, y=sales, group=sid, color=sid)) +
2010 Feb 03
1
color blending and transparency
I am using ggplot and posted this question at that helplist. It was
suggested that I try a more general R-help list for a possible solution to
this problem.
Within ggplot, I am using geom_area with red and blue and expect where they
overlap should be purple. But instead, it's dark red.
Playing with alpha and with different colors doesn't seem to solve the
problem.
Here's a very
2011 Jun 07
2
ggplot2 and facet
I have a data frame (attached) that has interpolated EOT errors for
each minute before flight landing. It also has the runway and an index
for the flight:
> > times[1:4,]
time error runway flight
1 0 -0.02206235 04R 1
2 1 -0.07961631 04R 1
3 2 -0.13795380 04R 1
4 3 -0.20726073 04R 1
> > sapply(times, class)
time error
2011 Mar 29
1
Multiple area plots to share the same x-axis
Hello,
I asked a similar question before but in an existing thread. I am not sure
if it is proper etiquette to repost a similar question as a new tread, I
think in this case, it might be because this way more people can see it and
perhaps learn from it. (Also, part of the existing thread became private)
I want to know how to plot multiple ggplot area plots on top of one another
so that the same