facet-grid

ggplot2 outside panel border when using facet

折月煮酒 提交于 2019-12-05 04:31:40
I would like to have a border around the outside of my faceted plot but not have the lines that separate the panels inside the plot. The issue is that panel.border draws a border around each panel in the facet with no option to just have a border around the entire plot. Alternatively can you set the inside dividing lines to 'white' but keep the outside border 'black'. Here is my code: mtcars mtcars$manufacturer=rownames(mtcars) ggplot(mtcars, aes(x=manufacturer, y=mpg,fill=factor(gear,levels=c("3","4","5"))))+ geom_bar(stat="identity",position="dodge",colour="black")+ facet_grid(~cyl,scales =

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

萝らか妹 提交于 2019-11-30 12:38:38
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 expression is not taken into account, for example : levels(a$group) <- c("control", expression("100 µg

geom_smooth with facet_grid and different fitting functions

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 12:08:50
First of all, apologies for the example, but I couldn't find a better data set to demonstrate the problem. Hopefully, it will suffice. Say I'm trying to make a facet grid of transmission (automatic vs. manual) and number of gears from the mtcars data set that plots mpg against displacement, like this: # Load library library(ggplot2) # Load data data(mtcars) # Plot data p <- ggplot(mtcars,aes(x = disp, y = mpg)) + geom_point() + facet_grid(gear ~ am) p <- p + geom_smooth() print(p) which gives, Notice, I've added a trend line using geom_smooth and it has defaulted to use a loess curve. I can

Seaborn FacetGrid PointPlot Label Data Points

六月ゝ 毕业季﹏ 提交于 2019-11-28 10:31:53
Given the following: import seaborn as sns attend = sns.load_dataset("attention") sns.set_style("whitegrid", {'axes.grid' : False,'axes.edgecolor':'none'}) g = sns.FacetGrid(attend, col="subject", col_wrap=5, size=1.5, ylim=(0, 10)) ax = g.map(sns.pointplot, "solutions", "score", scale=.7) I would like to label individual data points (put value labels in place of dots) on each line. In another plot that I created via MatPlotLib only, this was accomplished like this: for i, text in enumerate(ind): a.annotate(str(y[i])[:-2], xy=(ind[i], y[i]),fontsize=6, color=c, bbox=dict(pad=.9,alpha=1, fc=

geom_smooth with facet_grid and different fitting functions

妖精的绣舞 提交于 2019-11-28 05:06:24
问题 First of all, apologies for the example, but I couldn't find a better data set to demonstrate the problem. Hopefully, it will suffice. Say I'm trying to make a facet grid of transmission (automatic vs. manual) and number of gears from the mtcars data set that plots mpg against displacement, like this: # Load library library(ggplot2) # Load data data(mtcars) # Plot data p <- ggplot(mtcars,aes(x = disp, y = mpg)) + geom_point() + facet_grid(gear ~ am) p <- p + geom_smooth() print(p) which gives

Seaborn FacetGrid PointPlot Label Data Points

人盡茶涼 提交于 2019-11-27 03:41:36
问题 Given the following: import seaborn as sns attend = sns.load_dataset("attention") sns.set_style("whitegrid", {'axes.grid' : False,'axes.edgecolor':'none'}) g = sns.FacetGrid(attend, col="subject", col_wrap=5, size=1.5, ylim=(0, 10)) ax = g.map(sns.pointplot, "solutions", "score", scale=.7) I would like to label individual data points (put value labels in place of dots) on each line. In another plot that I created via MatPlotLib only, this was accomplished like this: for i, text in enumerate

How to order data by value within ggplot facets

允我心安 提交于 2019-11-26 22:59:34
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", "Osteoarthritis Pathway", "VDR/RXR Activation", "Axonal Guidance Signaling", "Basal Cell Carcinoma

Save a ggplot2 time series plot grob generated by ggplotGrob

旧巷老猫 提交于 2019-11-26 22:08:53
问题 This post describes a method to create a two-line x-axis (year below months) on a time series plot. Unfortunately, the method that I use from this post ( option 2 ) is not compatible with ggsave() . library(tidyverse) library(lubridate) df <- tibble( date = as.Date(41000:42000, origin = "1899-12-30"), value = c(rnorm(500, 5), rnorm(501, 10)) ) p <- ggplot(df, aes(date, value)) + geom_line() + geom_vline( xintercept = as.numeric(df$date[yday(df$date) == 1]), color = "grey60" ) + scale_x_date