facet-grid

How to implement the facet grid feature using the ggfortify library on a time series data?

旧巷老猫 提交于 2019-12-24 21:34:38
问题 I am using RStudio and I have a time series data ( ts object) called data1 . Here is how data1 looks: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2014 135 172 179 189 212 47 301 183 247 292 280 325 2015 471 243 386 235 388 257 344 526 363 261 189 173 2016 272 267 197 217 393 299 343 341 315 305 384 497 To plot the above, I have run this code: plot (data1) and I get the following plot: I want to have a plot that is broken by Year and I was thinking of implementing the facet_grid feature

y-axis for each subplot using facet_grid

て烟熏妆下的殇ゞ 提交于 2019-12-24 07:58:55
问题 I can't get the answer to this question to work. What both me and that user want is to add axis ticks and labels to all columns when using facet_grid(). Display y-axis for each subplot when faceting When I run the reproducable example and the solution (after adding abc=as.data.frame(abc) to fix the initial error) I receive an error message Error in gtable_add_grob(g, grobs = list(segmentsGrob(1, 0, 1, 1), segmentsGrob(1, : Not all inputs have either length 1 or same length same as 'grobs I

R : ggplot2 : facet_grid : how include math expressions in few (not all) labels?

偶尔善良 提交于 2019-12-18 15:48:11
问题 I get stuck with something on ggplot2 . I read most of the related posts, tried things but did not find any real solution. I want to include mathematical expressions in the label of my facet_grids with ggplot2 . In the raw file, I cannot write the name µg.L-1 In the titles and axis I can do it, for example : qplot(day, activity, data=a) +xlab(expression("100 µg "*.L^"-1"*"")) : this is working well. How do I do for the facet_labels ? I can set the levels and rename the labels factors but the

R : ggplot2 : facet_grid : how include math expressions in few (not all) labels?

可紊 提交于 2019-12-18 15:48:06
问题 I get stuck with something on ggplot2 . I read most of the related posts, tried things but did not find any real solution. I want to include mathematical expressions in the label of my facet_grids with ggplot2 . In the raw file, I cannot write the name µg.L-1 In the titles and axis I can do it, for example : qplot(day, activity, data=a) +xlab(expression("100 µg "*.L^"-1"*"")) : this is working well. How do I do for the facet_labels ? I can set the levels and rename the labels factors but the

How to order data by value within ggplot facets

六月ゝ 毕业季﹏ 提交于 2019-12-17 05:14:05
问题 I have the following data frame: library(tidyverse) tdat <- structure(list(term = c("Hepatic Fibrosis / Hepatic Stellate Cell Activation", "Cellular Effects of Sildenafil (Viagra)", "Epithelial Adherens Junction Signaling", "STAT3 Pathway", "Nitric Oxide Signaling in the Cardiovascular System", "LXR/RXR Activation", "NF-κB Signaling", "PTEN Signaling", "Gap Junction Signaling", "G-Protein Coupled Receptor Signaling", "Role of Osteoblasts, Osteoclasts and Chondrocytes in Rheumatoid Arthritis",

How to set background color for each plot in a facet grid using numeric values

两盒软妹~` 提交于 2019-12-14 02:41:44
问题 I would like to color the background of each individual plot to highlight the correlation. The whole think is an auto-correlation matrix plot of several time series. Following this, I almost got it work so far as you can easily understand with my super-simplified example: library(tidyverse) set.seed(214) n <- 1000 df <- tibble(v1 = runif(n), v2 = runif(n)*0.1 + v1, v3 = runif(n)*0.2 + v2, v4 = runif(n)*0.3 + v3, v5 = runif(n)*0.4 + v4, v6 = runif(n)*0.5 + v5) C <- crossing(w1 = 1:length(df),

faceting based on geom_point when ggplot() empty and multiple shaded geom_rect exist

对着背影说爱祢 提交于 2019-12-13 05:27:52
问题 I am attempting to shade multiple regions of interest on a scatter plot. Based on this answer, I believe I am forced to leave the intial ggplot() call empty, and supplie the geom_rect() calls before the geom_point() call. I have gotten all of this to work. I can not however apply a facet based on data passed to geom_point() . The following correctly plots my data (scatter plot over red and blue regions of different sizes): ggplot() + geom_rect(aes(xmin=885, xmax=1544, ymin=-Inf, ymax=Inf),

ggplot: How to create different x-axis titles with facet_grid

不羁的心 提交于 2019-12-12 18:11:51
问题 I have two plots that share the y-axis but have different x-axes. I used facet_grid to separate them appropriately (see figure), but the two x-axes need to have different titles (instead of the one title "Num Cell Lines.Tissue"). I've seen something similar done by creating 2 ggplot objects first then use a function like ggplotGrob. Is there a way to do this directly? Edit 1: to include data, code Data: Variable Condition Num.CellLines.Tissue Percent.Altered V1 C1 1 0.20149254 V1 C1 2 0

Alignment of y axis labels in faced_grid and ggplot?

岁酱吖の 提交于 2019-12-11 11:58:51
问题 By using ggplot and faced_grid functions I'm trying to make a heatmap. I have a categorical y axis, and I want y axis labels to be left aligned. When I use theme(axis.text.y.left = element_text(hjust = 0)) , each panels' labels are aligned independently. Here is the code: #data set.seed(1) gruplar <- NA for(i in 1:20) gruplar[i] <- paste(LETTERS[sample(c(1:20),sample(c(1:20),1),replace = T) ], sep="",collapse = "") gruplar <- cbind(gruplar,anagruplar=rep(1:4,each=5)) tarih <- data.frame(yil=

ggplot2: create a plot using selected facets with part data

我怕爱的太早我们不能终老 提交于 2019-12-11 11:50:03
问题 I would like to create a plot with Using part of the data to create a base plot with facet_grid of two columns. Use remaining part of the data and plot on top of the existing facets but using only a single column. The sample code: library(ggplot2) library(gridExtra) df2 <- data.frame(Class=rep(c('A','B','C'),each=20), Type=rep(rep(c('T1','T2'),each=10), 3), X=rep(rep(1:10,each=2), 3), Y=c(rep(seq(3,-3, length.out = 10),2), rep(seq(1,-4, length.out = 10),2), rep(seq(-2,-8, length.out = 10),2))