Quantcast
Viewing all articles
Browse latest Browse all 205372

Highlighting One of my Line Graphs in ggplot

Here is a link to my example data

What I want to do is create one graph with of only the values when the "Number" column has a 1 and with X on the X-Axis, Y on the Y-Axis and have multiple different colored lines on each graph based on the "Other" column. But I would like to be able to control the color of the line when Other = 2.

Here is what I have so far:

library(ggplot2)
library(RColorBrewer)
library(dplyr)

Data <- read.csv("Example_Data.csv")
Data <- na.omit(Data)

DF <- data.frame(
     DF1 <- Data[Data$Number == 1,],
     DF2 <- Data[Data$Number == 2,],
     DF3 <- Data[Data$Number == 3,]
)

Plot1 <- ggplot(data = DF1, aes(x = factor(Xaxis)), y = Yaxis, color = Other) +
  geom_line(aes(y = Yaxis, group = Other)) +
  geom_point(aes(y = Yaxis)) +
  labs(x = "X", y = "Y", title =  "Y vs X with Number = 1") +
  scale_color_gradientn(colors = rainbow(5)) +
  ylim(-1, 2)
Plot1

So all of that plots something like this: Image may be NSFW.
Clik here to view.
Plot I got

But none of my lines are colored and I do not know how to control the color of my specific Other = 2 line.

This is obviously made up data and the data I am actually working with has way more than just 3 values in my "Other" column, that is why I want to know how to control the color of just one of those lines. For example I'd like to have all of my colors different shades of the rainbow except for my specific value I'd want to be black.

Any help would be greatly appreciated.


Viewing all articles
Browse latest Browse all 205372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>