facet

R ggplot2 facet_wrap reordering subfigure and set different colors for each ID label

喜夏-厌秋 提交于 2020-01-15 05:06:27
问题 I am trying to reorder the subfigures order in ggplot facet_wrap and specify a certain color for their subfigure text label. Here is my dataset: ID <- rep(c('ABC123','DEF456','GHI789','JKL012'),each = 10) Vref <- c((runif(10,1,2)),(runif(10,3,5)),(runif(10,6,9)),(runif(10,0,2))) Time <- rep(c(1:10),4) df <- data.frame(ID,Vref,Time) ggplot(df) + geom_point(aes(x=Time, y=Vref)) + facet_wrap(~ID, nrow = 2) Now the order of subfigure is ABC123 --> DEF456 --> GHI789 --> JKL012. All text labels are

ggplot2: Change color for each facet in bar chart

给你一囗甜甜゛ 提交于 2020-01-13 05:43:34
问题 I have a faceted bar chart done with ggplot2 with this code: ggplot(data_long, aes(x=region, y=wert)) + geom_bar(aes(fill = kat ), position = "dodge", width=.5, stat="identity") + labs(y = "Wähleranteil [ % ]", x = NULL, fill = NULL) + facet_grid(. ~ type) + theme_bw() + theme( strip.background = element_blank(), panel.grid.major = element_line(colour = "grey80"), panel.border = element_blank(), axis.ticks = element_blank(), panel.grid.minor.x=element_blank(), panel.grid.major.x=element_blank

How to use ggplot2 facet colors and shapes?

让人想犯罪 __ 提交于 2020-01-11 14:09:52
问题 Maybe, I missed something in the ggplot grammar. The following 3 facets can be plotted without any error. Unfortuantely, the facet plots mixed up colors and shapes. The right hand column should show blue markers only, while the center one should have green markers. data1 num delay claim supply project 1 -236.347551 3000 DIF site1 2 65.132011 5000 Hoc site2 3 61.401260 5000 Hoc site2 4 96.902894 500 Hoc site2 .. base04 <- ggplot(data1, aes(num, delay, size=claim, color=supply, shape=project))

change line style in seaborn facet grid

我们两清 提交于 2020-01-11 06:43:29
问题 I have a data set like this import numpy as np; np.random.seed(3) import pandas as pd import seaborn.apionly as sns import matplotlib.pyplot as plt def get_data(n=266, s=[5,13]): val = np.c_[np.random.poisson(lam=s[0], size=n), np.random.poisson(lam=s[1], size=n)].T.flatten() comp = [s[0]]*n + [s[1]]*n ov = np.random.choice(list("ABC"), size=2*n) return pd.DataFrame({"val":val, "overlap":ov, "comp":comp}) data1 = get_data(s=[9,11]) data2 = get_data(s=[9,11]) data3 = get_data(s=[9,11])

How to generate facetted ggplot graph where each facet has ordered data?

∥☆過路亽.° 提交于 2020-01-07 02:56:12
问题 I want to sort my factors (Condition, Parameter and SubjectID) by MeanWeight and plot MeanWeight against SubjectID such that when faceted by Condition and Parameter, MeanWeight appears in descending order. Here is my solution, which isn't giving me what I want: dataSummary <- structure(list(SubjectID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L), .Label = c("s001", "s002", "s003", "s004"), class = "factor"), Condition = structure(c(1L, 1L, 1L, 2L, 2L,

Solr: Facet one field with two outputs

安稳与你 提交于 2020-01-05 08:51:53
问题 I'm using Solr for indexing products and organising them into several categories. Each document has a taxon_names multi value field, where the categories are stored as human readable strings for a product. Now I want to fetch all the categories from Solr and display them with clickable links to the user, without hitting the database again . At index time, I get the permalinks for every category from the MySQL database, which is stored as a multi value field taxon_permalinks . For generating

Solr faceting considering the availability of product at attribute combination level for e-commerce merchandise like Garment

风流意气都作罢 提交于 2020-01-05 03:48:10
问题 We are using Apache Solr for powering our search & faceting for the e-commerce website. We have a faceting filter that works fine except for the product that has the multiple combination for the attributes (variant options) that turns out to be different SKU, for example, a T-Shirt that has multiple colors & size options. Currently, we have a facet that filters by Color as well as by Size, however, it does not consider the availability of product on combination level due to the fact that it

How to write after decimal zero in ggplot (geom_text)

独自空忆成欢 提交于 2020-01-03 05:21:10
问题 I am wondering how i can put after decimal zero in the faceted ggplot plot. Following picture make it more clear. I would like to write r-squared =0.61 and 0.30 in two facets of ggplot using geom_text . It writes 0.61 properly but writes only 0.3 and not 0.30 in second plot. see the figure. My working data and codes are below. dput(ssdata) structure(list(Value = c(0.0776799352545487, 0.0249900650410425, 0.0530261633888124, 0.0567436050950435, 0.0120449632406235, 0.0148445528174501, 0

Extract single plot from ggplot with facet_grid

那年仲夏 提交于 2020-01-02 08:18:34
问题 I want to produce some plots using ggplot and facet_grid and save the plot as an object. My problem is that I also want to save each subgroup (i.e. each facet) as an object separately. My question is now if you can extract a single facet from facet_grid and save it as an object? Here is some simple code: library(ggplot2) ggplot(data = mtcars, aes(x = disp, y = mpg)) + geom_point() + facet_grid(. ~ am) Now I'd like to produce two objects - one for am=0 and one for am=1 . 回答1: I'm not sure why

R: {ggplot2}: How / Can I independently adjust the x-axis limits on a facet_grid plot?

谁说我不能喝 提交于 2020-01-02 04:27:05
问题 I created a faceted set of three univariate densities -- comparing MCMC methods. Shown below For the moment, I don't care about the tails. So how can I change the x-axis limits on the plots above to be: c(-3,1) c(-2,0) c(-10, -8) Is this even possible? I've already read this thread from 2009, but it doesn't seem to work. Was this implemented? 回答1: You can always allow limits to be set independently for each facet by specifying + facet_wrap(...,scales = "free_x") There are also "free" and