0

I have a complicated scatterplot that has a legend that is not correctly ordered.

sample of my data: Sample of my data from excel I have used the following code to generate my graph and order the category "Day"

Day <- factor(Day, levels = c("One", "Five", "Ten", "Fifteen", "Twenty"))
ggplot(Exp6data, aes(x=Temperature, y=Age, color = Day, shape = Day, fill = Day)) +
 geom_point(aes(size=Day)) + 
 geom_smooth(method = lm, se = FALSE, fullrange = FALSE) + 
 labs(x="Temperature",y="Age - Legend") + 
 scale_shape_manual(values=c(18,1,15,4,17)) + 
 scale_size_manual(values=c(3,3,3,3,3)) + 
 scale_color_manual(values=c('#696969', '#A9A9A9', '#C0C0C0', '#808080', '#000000')) +
 scale_fill_discrete(breaks=c('One', 'Five', 'Ten', 'Fifteen', 'Twenty')) +
 theme_classic()

My graph generated from my data - with two different legends present

Thank you in advance for any useful advice.

stefan
  • 90,330
  • 6
  • 25
  • 51
NJP
  • 1
  • 2
  • 1
    Please do not post an image of code/data/errors [for these reasons](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question/285557#285557). Just include the code, console output, or data (e.g., dput(head(x)) or data.frame(...)) directly. For more on that see [how to provide a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – stefan Oct 03 '22 at 21:12
  • Do you have a column in Exp6data called `Day`, as well as a free-floating vector called `Day`? The latter one looks sorted but won't have any bearing on the sorting of the former. – Jon Spring Oct 03 '22 at 23:12
  • I dont understand your first comment. I posted code in a code block. I have a column in Exp6data called Day that I sorted into different levels. I dont have another vector also called Day as the only one I have is the one in my original data and I didnt create another one.. I dont think? – NJP Oct 04 '22 at 06:26
  • I see that my excel table loaded as an image. I do not know how to link it as not an image – NJP Oct 04 '22 at 06:37

0 Answers0