I have three matrix and I want to plot the graph using ggplot2. I have the data below.
library(cluster)
require(ggplot2)
require(scales)
require(reshape2)
data(ruspini)
x <- as.matrix(ruspini[-1])
w <- matrix(W[4,])
df <- melt(data.frame(max_Wmk, min_Wmk, w, my_time = 1:10), id.var = 'my_time')
ggplot(df, aes(colour = variable, x = my_time, y = value)) +
geom_point(size = 3) +
geom_line() +
scale_y_continuous(labels = comma) +
theme_minimal()
I want to add the three plots into one plot using a beautiful ggplot2. Moreover, I want to make the points with different values have different colors.
I'm not quite sure what you're after, here's a guess
Your data...
Slight modification to your base plot code to make it work...
Is this what you meant?
If you want to reproduce this with
ggplot2, you might do something like this...UPDATE after the question was edited and the example data changed, here's an edit to suit the new example data:
Here's your example data (there's scope for simplification and speed gains here, but that's another question):
Here's what you need to do to make the three objects into vectors so you can make the data frame as expected:
Now reshape and plot as before...
And here's the result: