-2

Data is as follows

Data

I can't seem to find the answer to the following, but I have a ggplot2 that I want to change the points on the plot to black & white and shapes of square, circle, closed square and closed circle.

The code is as specified:

library(ggplot2)
Horticulture$Species<-factor(Horticulture$Species)
Horticulture$Speciesf<-factor(paste("ID",Horticulture$Species,sep=" "))
ggplot(Horticulture,aes(x=Time,y=growth,col=Horitculture:Speciesf))+
  geom_point()+geom_errorbar(aes(ymin=growth-SE,ymax=growth+SE))+
  geom_line() + xlab("Time [days]")+
  theme_bw(legend.title=element_blank(),
           legend.position = c(0.85, 0.85))+
  ylab(expression(paste("Growth [",days,"per measurement")))```
Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
Adelina
  • 7
  • 3
  • 1
    See [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) – TarJae Dec 11 '22 at 19:30
  • When you put `col` that means color. If you want to use shape instead of color to distinguish your points, change `col` to `shape`. – Gregor Thomas Dec 11 '22 at 19:57

1 Answers1

0

Does this give you what you need?

# Load the required packages
library(ggplot2)

# Create a sample data frame
Horticulture <- data.frame(
  species = rep(letters[1:4], 10),
  Time = rep(1:10,each = 4),
  growth = rnorm(40, 1.3, 0.4),
  SE = rnorm(40,0.1,0.1))

# generate plot
ggplot(Horticulture,aes(x=Time, y=growth, shape=species))+
  geom_point() + geom_errorbar(aes(ymin=growth-SE,ymax=growth+SE))+
  geom_line() + xlab("Time [days]")+
  ylab(expression(paste("Growth [",days,"per measurement"))) +
  scale_shape_manual(values = c(0,1,15,16))
user1827208
  • 11
  • 1
  • 3