3
df<-age_limbset
df$limbset<-as.factor(df$limbset)
limb_splot<-ggplot(df, aes(x=age,y=score))
limb_splot +
  geom_point(aes(color = limbset, shape = limbset))+
  geom_smooth(aes(color = limbset),
              method = loess, se = FALSE, fullrange = TRUE)+
  scale_color_manual(values = c("blue","hotpink"))+
  scale_fill_manual(values = c("blue","hotpink"))+
  ggpubr::stat_cor(aes(color = limbset),method="spearman", label.x = 3)+
  labs(x="Age (years)",y="Total proprioception score (0-4)")+
  scale_y_continuous(breaks=seq(0,4,0.5))+
  scale_x_continuous(breaks=seq(2,16,2))+
  theme_bw()

Sorry I do not know how to enter data here. I have created this scatterplot showing relationship between age and proprioception of both forelimbs and hindlimbs. The plot is listening to my instruction for the x axis limits and breaks, but I can only get it to listen to either the limits OR the breaks for the y axis. What am I doing wrong? How can I change the symbols for the data points? Ideally I would like them all to be dots. I would also like to change the legend name and labels to start with a capital letter.

scatterplot

MrFlick
  • 195,160
  • 17
  • 277
  • 295
Lucie
  • 31
  • 1
  • 2
  • 3
    See [how to create a reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for suggestions for including data so we can actually run and test the code. – MrFlick May 04 '22 at 15:58
  • 1
    Difficult to help when you don't show the code that is failing (i.e. the axis limits). But make sure you define the limits in the scales you are already using, so use e.g. `scale_y_continuous(breaks=seq(0,4,0.5), limits = c(0, 1))`, not `scale_y_continuous(breaks=seq(0,4,0.5)) + ylim(0, 1)`. To change the symbols, see `?scale_shape_manual`. – Axeman May 04 '22 at 16:04
  • If you don't want different shapes, you need to remove the `shapes = limbset` from your aesthetics. (Please limit to 1 question per post) – Andrea M May 04 '22 at 16:08
  • I do apologise @Axeman , please understand I am new to this forum AND RStudio hence my struggles! I am reading the article from MrFlick on how to add this but it is all alien language to me I'm afraid – Lucie May 04 '22 at 16:09

1 Answers1

3

Here's an example of a reproducible example which also addresses your questions, e.g. with scale_shape_manual to get the shapes you want which you could choose here.

library(tidyverse)

tibble(years = rep(seq(2, 16, 1), 2),
       score = abs(rnorm(30, 10, 10)),
       set = rep(c("fore", "hind"), 15)
) |> 
  ggplot(aes(years, score, shape = set, colour = set)) +
  geom_point() +
  scale_shape_manual(values = c(1, 10)) +
  scale_y_continuous(limits = c(0, 40), breaks = seq(0, 40, 5)) +
  labs(x = "Years", y = "Score", shape = "Set", colour = "Set")

Created on 2022-05-04 by the reprex package (v2.0.1)

Carl
  • 4,232
  • 2
  • 12
  • 24