0

I'm learning R and I created a basic ggplot() with the code below:

ggplot(aes(ACTIVITY_X, ACTIVITY_Y, color = as.factor(cluster), shape = Event)) + geom_point(size=3) + xlab("Axis X") + ylab("Axis Y") + labs(color="Cluster") + labs(shape="Dominant behaviour") 



p + theme_classic()

This is an actual picture of it: enter image description here

I would like to edit the labels below Cluster, so that they become "Standing","Feeding" and "Foraging".

How can I edit labels from a factor call? I've tried this earlier with no luck:

+   ggplot(aes(ACTIVITY_X, ACTIVITY_Y, color = as.factor(cluster,
+                                                        labels = "Standing", 
+                                                                               "Feeding", "Foraging"))
+              , shape = Event) +
+   geom_point(size=3) + xlab("Axis X") + ylab("Axis Y") + labs(color="Cluster") + labs(shape="Dominant behaviour")
> 
>         
> 
> p + theme_classic()
Error in as.factor(cluster, labels = "Standing", "Feeding", "Foraging") : 
  unused arguments (labels = "Standing", "Feeding", "Foraging")

Also, I would like to increase the size of all text in the plot, including axis labels and legends.

Any input is appreciated!

juansalix
  • 503
  • 1
  • 8
  • 21
  • Don't use `as.factor()`, just use `factor()` and all your labels need to be in a vector, not separate parameters. For example `factor(cluster, labels=c("Standing", "Feeding","Foraging"))` – MrFlick May 06 '19 at 15:24
  • @MrFlick Thank you, that worked. How can I increase the size of the legend though from within a `factor()` call (and other text as well)? – juansalix May 06 '19 at 15:36
  • Legend size comes from `theme` arguments; it's got nothing to do with creating a factor – camille May 06 '19 at 16:00
  • You should just ask one question at a time with a Stack Overflow post. This [previous question](https://stackoverflow.com/questions/20407773/increase-legend-font-size-ggplot2) will probably help with resizing legends, or [this one](https://stackoverflow.com/questions/11955229/how-to-change-the-default-font-size-in-ggplot2) for all text. – MrFlick May 06 '19 at 16:02

0 Answers0