facet

Ownership/delete'ing the facet in a locale (std::locale)

为君一笑 提交于 2019-12-06 17:18:28
问题 I wrote the following function to get a date/time string using boost.date_time. namespace bpt = boost::posix_time; string get_date_time_string(bpt::ptime time) { bpt::time_facet * facet(new bpt::time_facet); facet->format("%Y%m%d%H%M%S"); stringstream return_value; return_value.imbue(std::locale(std::locale::classic(), facet)); return_value << time; return return_value.str(); } I had a quick question about the ownership/ delete 'ing of the facet object. std::locale's constructor is not

How to set different y-axis scale in a facet_grid with ggplot?

主宰稳场 提交于 2019-12-06 15:22:52
问题 I have this dataframe C_Em_df structure(list(Driver = c("Crop agriculture", "Infrastructure", "Mining", "Mixed Agriculture", "Other land use", "Pasture", "Tree crops", "Water", "Crop agriculture", "Infrastructure", "Mining", "Mixed Agriculture", "Other land use", "Pasture", "Tree crops", "Water", "Crop agriculture", "Infrastructure", "Mining", "Mixed Agriculture", "Other land use", "Pasture", "Tree crops", "Water", "Crop agriculture", "Infrastructure", "Mining", "Mixed Agriculture", "Other

Add text to ggplot with facetted densities

坚强是说给别人听的谎言 提交于 2019-12-06 12:28:41
问题 I'm encountering a problem when trying to make a density plot with ggplot. The data look a bit like in the example here. require(ggplot2) require(plyr) mms <- data.frame(deliciousness = rnorm(100), type=sample(as.factor(c("peanut", "regular")), 100, replace=TRUE), color=sample(as.factor(c("red", "green", "yellow", "brown")), 100, replace=TRUE)) mms.cor <- ddply(.data=mms, .(type, color), summarize, n=paste("n =", length(deliciousness))) plot <- ggplot(data=mms, aes(x=deliciousness)) + geom

Sorting factors in multipanel plot in ggplot2 according to the first panel

烈酒焚心 提交于 2019-12-06 12:07:47
Is it possible to sort factors in a multipanel plot in ggplot2 according to the first panel? The first panel decides the order and the remaining panels follow that order. Here is an example: require(ggplot2) set.seed(36) xx<-data.frame(YEAR=rep(c("X","Y"), each=20), CLONE=rep(c("A","B","C","D","E"), each=4, 2), TREAT=rep(c("T1","T2","T3","C"), 10), VALUE=sample(c(1:10), 40, replace=T)) ggplot(xx, aes(x=CLONE, y=VALUE, fill=YEAR)) + geom_bar(stat="identity", position="dodge") + facet_wrap(~TREAT) Which gives me this plot: Now I would like to sort CLONE based on the VALUE in YEAR X in a

geom_raster faceted plot with ggplot2: control row height

こ雲淡風輕ζ 提交于 2019-12-06 11:16:09
In the example below I have a dataset containing two experiments F1 and F2. A classification is performed based on F1 signal, and both F1 and F2 values are ordered accordingly. In this diagram, each facet has the same dimension although the number of rows is not the same ( e.g class #7 contains only few elements compare to the other classes). I would like to modify the code to force row height to be the same across facets (facets would thus have various blank space below). Any hints would be greatly appreciated. Thank you library(ggplot2) library(reshape2) set.seed(123) # let's create a fake

ggplot2 control number of panels per row when using facet?

跟風遠走 提交于 2019-12-06 11:06:16
问题 Is it possible to control the number of panels per row in a ggplot? I can only get an equal number of panels on each row as in the example plot below. For example I have data that is naturally grouped into 22 blocks by 'Marker' which in turn are organised by 'Dye' (see example code and data below). In this example I would like to arrange the panels in 4 rows with 5, 6, 6, and 5 panels respectively on each row (as in the picture at the end, but the 22 blocks can be equally wide). Example code:

Changing the breaks and limits in a facet_grid where scales=“free_y”

半城伤御伤魂 提交于 2019-12-06 09:51:22
Is possible to control separately the limits and the breaks of a given axis ( x of y ) when the facet_grid uses the `scales="free_smth" parameter? I have a plot where I have used `facet_grid(scales="free_y") because the faceted data are of different orders of magnitude. Now I would like to control separately the limit of the y axis for each of those grids: for example make each of the y axis 10% longer? Is there a way to achieve that? For the breaks I found this post: Change the number of breaks using facet_grid in ggplot2 dput(mod) structure(list(clusteringDistance = c(0, 0, 0, 0, 0, 0, 0, 0,

ggplot facet_wrap with specific order of variables in each facet

北城以北 提交于 2019-12-06 06:31:41
I would like to plot these data with ggplot: library(ggplot2) set.seed(0) df <- data.frame( var1 = rep(c("group1", "group2"), each = 3), var2 = rep(letters[1:3], 2), value = runif(6, 0, 10) ) The plot should be faceted like this: pl <- ggplot(df, aes(var2, value)) pl <- pl + geom_col() pl <- pl + facet_wrap(~ var1, scales = "free") pl The order of var2 on the x-axis should be determined by increasing order of value . I could achieve this doing: df$temp_var <- paste(df$var1, df$var2) pl <- ggplot(df, aes(reorder(temp_var, value), value)) pl <- pl + geom_col() pl <- pl + facet_wrap(~ var1,

Django Haystack Faceting examples

亡梦爱人 提交于 2019-12-06 06:28:02
I want to use Django-Haystack-Solr in a site I am working on. I have worked through the examples in the Haystack documentation and have searched the internet extensively for other examples. I am having difficulty making the leap to integrating it in my site. I found http://www.slideshare.net/Nagyman/faceted-navigation-using-django-haystack-and-solr interesting, but fell short of how to pull it all together. If anyone has run across some "robust" Haystack faceting examples, websites that are open-source, or would be willing to share some of your own code please provide links/share code. Thanks

faceted piechart with ggplot

我们两清 提交于 2019-12-06 06:16:13
问题 I have the following data.frame: x = data.frame(category=c(1,1,1,1,2,2,2,2), value=c(1,2,1,1,2,2,2,1)); x$category = as.factor(x$category); x$value = as.factor(x$value); and I have created a faceted bar chart with ggplot2. ggplot(x, aes(value, fill=category)) + geom_bar() + facet_wrap(~category); However, I would like to have a pie chart that shows the fraction values (based on the totals for each category). The diagram should then show one pie chart for each category and two fractions inside