1

This is probably going to sound like a really stupid question but my plot in R will not change color!

this is my line in R

plot(MasterModCfs$V3,MasterModCfs$V5,col="blue")

I have tried it with spaces and without, with different colors, reloading, everything I could think of. If it's important, MasterModCfs contains literally thousands of data values.

I did one of the examples just to check

cars <- c(1, 3, 6, 4, 9)
plot(cars)
plot(cars, col="blue")

and it's blue. So that works.

Why won't my plot change colors?

thelatemail
  • 91,185
  • 12
  • 128
  • 188
user3736201
  • 99
  • 2
  • 6

3 Answers3

2

Googling the same problem, I came across this present page - but subsequently found the source of my own issue through trial and error so posting here in case it helps. My x axis values were set up as factors - when I re-converted them to a normal string using as.character(), I was able to re-apply my own colours finally.

GoingMush
  • 45
  • 1
  • 7
  • Mine was in POSIXct format and didn't work. Change it to as.Date and it worked. Hope this helps others. – TheSciGuy Apr 18 '19 at 14:58
0

Without knowing what your par() settings are and what the classes of your columns, it's impossible to say.

You might try adding 'pch=21, bg="red"' to your plot command and see if that changes anything. It might give you a hint.

kendaop
  • 107
  • 2
  • 13
0

I suggest using the aes command in ggplot2. You can try

ggplot(data = MasterModCfs) + geom_point (mapping =aes (x=V3, y=V5), color="blue")

That should work!

Using plot directly I am not sure how to do it. I try your simple example (with cars) but it also fails if you add another vector for the "y" axis (as you wish to do in the end). To be honest, I have no idea why it works using only "cars" and the color.

Jan Boyer
  • 1,540
  • 2
  • 14
  • 22