facet

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))

overlapping y-scales in facet (scale=“free”)

坚强是说给别人听的谎言 提交于 2019-12-11 10:11:13
问题 I've been learning ggplot in the last few weeks. Generally, I'm getting things done (slowly though), but now I'm stuck. I created the following facetted plot: http://dl.dropbox.com/u/7752237/example_bad_y_scales.pdf Faceting is done by pl <- pl + facet_wrap(~sci_name,ncol=1,scale="free") The Problem: Numbers on the y-scale don't look good, especially the scales that go from 0-70 (numbers overlapping). I'd like the somehow change the number of breaks on the y-scale (to let's say just 1 or 2

Multiple plots by factor in ggplot (facets)

穿精又带淫゛_ 提交于 2019-12-11 09:37:36
问题 I have a data frame with two qualitative variables (Q1, Q2) which are both measured on a scale of LOW, MEDIUM, HIGH and a continuous variable CV on a scale 0-100. s = 5 trial <- data.frame(id = c(1:s), Q1 = ordered(sample(c("LOW","MED","HIGH"),size=s,replace=T)), Q2 = ordered(sample(c("LOW","MED","HIGH"),size=s,replace=T)), CV = runif(s,0,100)) I need to use ggplot to show a faceted plot (preferably a horizontal boxplot/jitter) of the continous variable for each qualitative variable (x2) for

Elastic Search - display all distinct values of an array

狂风中的少年 提交于 2019-12-11 08:36:57
问题 For a field mapped as string I have stored list of strings in the ES index, for ex: subject: ["Scientific Research", "Numerical Analysis", "History of Art"] I would like to query this field and retrieve the full names of categories with their frequency count. What I tried so far with facets: "query":{ "match_all": {} }, "facets":{ "tag":{ "terms":{ "field":"subject"} } } is not working as expected because it splits my subject fields into tokens and returns me the top most frequent stopwords.

Wrong axis labels for ggplot facet grid

只谈情不闲聊 提交于 2019-12-11 08:05:33
问题 I was answering this question that I faced a strange problem; I want to make a bar plot with ggplot2 and have x axis labels as the last character of Group column. Use substring(Group, 3, 3) for this purpose: substring(df$Group, 3, 3) # [1] "1" "2" "3" "1" "2" "1" "2" "3" "4" But when I use it in ggplot like below, it prints 1 instead of 4 at the last tick; ggplot(data=df, aes(x=Group, y=Value)) + geom_bar(stat="identity") + scale_x_discrete(labels = substring(Group, 3, 3), expand=c(0.1,0.1))

Using multiple facets in MongoDB Spring Data

百般思念 提交于 2019-12-11 07:53:35
问题 I want to run multiple facets in one aggregation to save db round trips. Here is my spring data code : final BalancesDTO total = this.mongoTemplate.aggregate( newAggregation( /* * Get all fund transactions for this user */ match(where("userId").is(userId)), /* * Summarize Confirmed Debits */ facet( match(where("entryType").is(EntryType.DEBIT) .andOperator(where("currentStatus").is(TransactionStatus.CONFIRMED))), unwind("history"), match(where("history.status").is(TransactionStatus.CONFIRMED))

SORL facet fields order by descending value

匆匆过客 提交于 2019-12-11 05:26:18
问题 I am using SOLR 6.5.1 with facet filters. My query has: facet.limit=-1 --> to generate all possible facets values facet.sort=index --> to order facets values not by number of occurrences but by the value itsef For instance, one facet has integers as values (in particular the fields contains years). So the values are (occurences in brackets): 2010 (438) 2011 (547) ... 2017 (367) The facet is correctly ordered by value but with asc order (2010-->2017). How can obtaint the reverse order (2017--

(ROSE plot error) Error: Faceting variables must have at least one value

邮差的信 提交于 2019-12-11 04:47:46
问题 I am trying to plot monthly roseplots in R using the code below but I am encountering an error: "Error: Faceting variables must have at least one value" Here is the data that I am using Link to data This code came from a previous post: Rose plot using ggplot require(ggplot2) require(RColorBrewer) require(scales) plot.windrose <- function(data, spd, dir, spdres = 2, dirres = 22.5, spdmin = 2, spdmax = 20, spdseq = NULL, palette = "YlGnBu", countmax = NA, debug = 0){ # Look to see what data was

ggplot2 with dual axis

空扰寡人 提交于 2019-12-11 04:26:06
问题 This is an extension of this question. I am currently using the most recent version of ggplot2 (v2.2.0) from CRAN to create plots within R . I am making use of the solution provided by @Axeman here. The trouble I have is that when I use facets sometimes one of the y-axes shows very small values. I am wondering if someone has a clean solutions so that both y-axes can be scaled appropriately. Reproducible example: library(data.table) library(ggplot2) library(scales) dt1 <- data.table(diamonds)

Faceting plots by combinations of columns in ggplot2

二次信任 提交于 2019-12-11 04:09:28
问题 I am doing combinations of correlations, and would like to plot in ggplot2 each combination. However I want each combination on a separate panel, rather than all the points on one panel. #making up columns, in my real data I'm doing correlations between each column (ie. col1~col2, col1~col3, col2~col3) col1 <- c(1:10) col2 <- c(12:3) col3 <- c(10, 12, 18, 19, 20, 30, 31, 32, 40, 41) df <- data.frame(col1, col2, col3) g <- ggplot(data=df, aes(x=col1, y=col3)) + geom_point() I knew this wouldn