]> git.vanrenterghem.biz Git - www2.vanrenterghem.biz.git/blobdiff - posts/facet_labels_in_R.org
Gebruik source folder.
[www2.vanrenterghem.biz.git] / posts / facet_labels_in_R.org
diff --git a/posts/facet_labels_in_R.org b/posts/facet_labels_in_R.org
deleted file mode 100644 (file)
index 609a8ee..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#+date: 2016-10-05 21:48:11 +0800
-#+title: Facet labels in R
-#+filetags: R graph code
-
-Getting used to the grammar of ggplot2 takes some time, but so far it's not been disappointing. Wanting to split a
-scatterplot by segment, I used =facet_grid=. That by default shows a
-label on each subplot, using the values in the variable by which the
-plot is faceted.
-
-As that often isn't very descriptive in itself, there needs to be a way
-to re-label these subplots. That way is =as_labeller=, as shown in the
-example code below.
-
-Example:
-#+BEGIN_SRC R
-ggplot(outputs, aes(x = date_var,y = value_var), alpha = 0.8) + 
-  geom_point(aes(y = value_var, colour = colour_var)) + 
-  geom_smooth() + 
-  theme(legend.position = "none",
-        axis.text.y = element_blank(),
-       axis.text.x = element_blank()) +
-  scale_x_date(date_breaks = '1 week') + 
-  labs(y = "Value", x = "Date",
-  title = "Example") +
-  scale_colour_manual("Legend", values = named_coloring_vector)) +
-  scale_fill_manual(“", values = c("grey12”)) + facet_grid(. ~ Segment,
-  labeller = as_labeller(c("yes" = "Segment A", "no" = "Segment B")))
-#+END_SRC
-
-Output: 
-#+CAPTION: Example plot with 2 facets labelled Segment B and Segment A.
-#+ATTR_HTML: :class img-fluid :alt Example plot with 2 facets labelled Segment B and Segment A.
-[[file:../assets/2016-10-05_R-facet.png]]