facet-grid

Highlight / Draw a box around some of the plots when using `facet_grid` in ggplot2

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-19 05:01:32
问题 I am creating a matrix of plots similar to ggplot(mpg, aes(displ, hwy)) + geom_point() + facet_grid(rows = vars(cyl), cols = vars(drv)) Now, I would like to have some way to highlight some of the individual plots, say the ones where cyl is 5 or 6, and drv is f . So, ideally, this might look like this: But I would also be happy with those panels having a different look by setting ggtheme to classic or similar. However, it is very unclear to me how I can modify individually selected plots

How to use italic in label_bquote for strip text lables

天大地大妈咪最大 提交于 2021-02-11 14:29:58
问题 There have been many proposed solutions to many slightly different problems, but none quite catches my specific problem. What I want is the following: I want to mix normal subfig labels (a, b, c, ...) with species names in italics . So far, I only want do this for four species, so I could live with a manual solution. But a custom function automatizing the process would be neat... E.g. the strip text of species a would be: a) Genus species Here is a reproducible example with the iris dataset:

Labeling: Facet grid with multiple lines of text on y label

℡╲_俬逩灬. 提交于 2021-02-11 04:58:39
问题 I have a plotly graph made in ggplot2. I am displaying the graphics using face_grid but the y axis is very long. Because of this not all the words on the y axis are visible. Is there a way to split the text into two lines such that the entire y axis is visible? majors.sub.HS<- majors.sub[, c(8:10, 66)] majors.sub.HS<-melt(majors.sub.HS, id.vars = "Major" ) majors.sub.HS$value[majors.sub.HS$value=="5- Highly Supported"] <- 5 majors.sub.HS$value[majors.sub.HS$value=="1- Not Supported"] <- 1

Labeling: Facet grid with multiple lines of text on y label

≡放荡痞女 提交于 2021-02-11 04:56:14
问题 I have a plotly graph made in ggplot2. I am displaying the graphics using face_grid but the y axis is very long. Because of this not all the words on the y axis are visible. Is there a way to split the text into two lines such that the entire y axis is visible? majors.sub.HS<- majors.sub[, c(8:10, 66)] majors.sub.HS<-melt(majors.sub.HS, id.vars = "Major" ) majors.sub.HS$value[majors.sub.HS$value=="5- Highly Supported"] <- 5 majors.sub.HS$value[majors.sub.HS$value=="1- Not Supported"] <- 1

Independent alpha for each plot within facet_grid based on density

本秂侑毒 提交于 2021-02-08 04:36:38
问题 I am constructing a facet_grid using stat_hexbin however I would like the alpha value to be independent for each of the facet plots. I am currently using the following code: ggplot (data, aes (x, y , fill = z)) + stat_binhex(bins=20, aes(alpha = ..count..)) + facet_grid(. ~ z) + guides(alpha = F) + coord_equal() + theme_bw() which produces the following plot: However, the alpha value, which is defined by ..count.. doesn't work when applied outside of the aes within stat_binhex . I would like

ggplot2 problems with using …prop… and grouping bar graph by another category

99封情书 提交于 2021-01-27 11:46:17
问题 StudentData <- data.frame(gender = sample( c("male","female"), 100, replace=TRUE), degree = sample( c("Associates", "Masters", "PhD"), 100, replace=TRUE), category = sample( c("Audit", "Credit"), 100, replace=TRUE)) In the following dataset, I am trying to create a bar graph that plots the percentage of the sample which have an Associate's, Master's, or PhD, separated by gender (done by using facet_grid() ). This is what I have generated so far: StudentData %>% ggplot(., aes(x=degree, group

ggplot2 problems with using …prop… and grouping bar graph by another category

心不动则不痛 提交于 2021-01-27 11:39:50
问题 StudentData <- data.frame(gender = sample( c("male","female"), 100, replace=TRUE), degree = sample( c("Associates", "Masters", "PhD"), 100, replace=TRUE), category = sample( c("Audit", "Credit"), 100, replace=TRUE)) In the following dataset, I am trying to create a bar graph that plots the percentage of the sample which have an Associate's, Master's, or PhD, separated by gender (done by using facet_grid() ). This is what I have generated so far: StudentData %>% ggplot(., aes(x=degree, group

Draw a horizontal line line at specific position/annotate a Facetgrid in seaborn

天大地大妈咪最大 提交于 2021-01-20 19:08:31
问题 A have produced a boxplot with Facetgrid in seaborn the following way # Import the dataset tips = sns.load_dataset("tips") # Plot using Facegrid, separated by smoke plt.style.use('ggplot') g = sns.FacetGrid(tips, col="smoker", size=5, aspect=1.5) g.map(sns.boxplot, "sex", "total_bill", palette='viridis', order=['Male', 'Female']) plt.show() I now want to draw to distinct horizontal lines in each of the plot. For instance one horizontal line (with coordinated (0,10)) only in the left-hand side

Draw a horizontal line line at specific position/annotate a Facetgrid in seaborn

孤者浪人 提交于 2021-01-20 18:57:58
问题 A have produced a boxplot with Facetgrid in seaborn the following way # Import the dataset tips = sns.load_dataset("tips") # Plot using Facegrid, separated by smoke plt.style.use('ggplot') g = sns.FacetGrid(tips, col="smoker", size=5, aspect=1.5) g.map(sns.boxplot, "sex", "total_bill", palette='viridis', order=['Male', 'Female']) plt.show() I now want to draw to distinct horizontal lines in each of the plot. For instance one horizontal line (with coordinated (0,10)) only in the left-hand side

Rotate switched facet labels in ggplot2 facet_grid

天涯浪子 提交于 2020-11-30 04:30:50
问题 I would like to plot some barplots on top of each other using facet_grid: library(ggplot2) df <- group_by(mpg, manufacturer) %>% summarise(cty = mean(cty), hwy = mean(hwy)) %>% ungroup() df <- melt(df, id.vars = "manufacturer") ggplot() + geom_bar(data =df, aes(x = variable, y = value), stat = "identity") + facet_grid(manufacturer ~ ., switch = "y") I use the switch argument of ggplot2::facet_grid() to let the facet labels be displayed on the y-axis instead of on top of each facet. Problem is