如何生成图例标题和ggplot + geom_point的标签?

时间:2019-02-03 14:58:57

标签: r ggplot2 plot

我正在努力为ggplot + geom_point生成图例及其标签。

以下是我的代码

# Create an index to hold values of m from 1 to 100
m_index <- (1:100)

# Creating data frames to store the correlations
data_frame_50 <- data.frame(prob_max_abs_cor_50)
data_frame_20 <- data.frame(prob_max_abs_cor_20)


library(ggplot2)




# Plot correlations using ggplot and geom_point 
ggplot() +
geom_point(data = data_frame_50, aes(x = m_index, y  = prob_max_abs_cor_50),  
 colour = 'red') +
geom_point(data = data_frame_20, aes(x = m_index, y = prob_max_abs_cor_20),
 colour = 'blue') +
labs(x = " Values of m  ", y = " Maximum Absolute Correlation ",
 title = "Dot plot of probability")

enter image description here

0 个答案:

没有答案