Changing labels of facets in mt_plot
Hello!
I am plotting trajectory types. I want to change the facet columns' names to something else. I tried the following with no luck:
facet_labels = c("35%", "25%", "10%", "5%", "5%")
mt_plot(mt_data,
use2 = "prototyping",
facet_col = "prototype_label",
alpha = .05)
+ facet_wrap(labeller = as_labeller(facet_labels))
This throws the following error:
Error in facet_wrap(labeller = as_labeller(facet_labels)) : argument "facets" is missing, with no default
What should I do?
Comments
Hi there,
to change the labels of facets, the names of the factor levels need to be modified.
One issue with the specific labels suggest above is that it is not possible to use the same label twice (otherwise the corresponding data will be merged to one category).
In this example above:
mt_data$prototyping$prototype_label <- factor( mt_data$prototyping$prototype_label, # Old levels (I assume you are using the standard prototypes here) levels = c("straight", "curved", "cCoM", "dCoM", "dCoM2"), # New levels (in same order) # (note that I added a space to the second level so it is distinct from the first) labels = c("35%", "25%", "10%", "5%", "5% ") ) mt_plot(mt_data, use2 = "prototyping", facet_col = "prototype_label", alpha = .05)Best,
Pascal