我正在努力为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")