I have used the following code to create the attached graph:
# Load required library
library(ggplot2)
library(ggmulti)
# Simulate data
set.seed(123) # Set a seed for reproducibility
n_points <- 100 # Number of data points
# Simulate values for Loading variables l1, l2, l3, l4, l5, and l6
l1 <- rnorm(n_points)
l2 <- rnorm(n_points)
l3 <- rnorm(n_points)
l4 <- rnorm(n_points)
l5 <- rnorm(n_points)
l6 <- rnorm(n_points)
# Create a labelling variable with categories
labelling <- factor(sample(1:3, n_points, replace = TRUE))
# Create a data frame with the simulated data
dataplot <- data.frame(l1, l2, l3, l4, l5, l6, labelling)
# Create the plot using ggplot
p <- ggplot(dataplot,
aes(
Loading1 = l1,
Loading2 = l2,
Loading3 = l3,
Loading4 = l4,
Loading5 = l5,
Loading6 = l6,
color = labelling
))
geom_path(alpha = 0.2)
theme_bw()
scale_shape_manual(values = 7)
coord_serialaxes()
# Display the plot
print(p)
My questions: How can I change the labels used in the legend to make them more visible e.g. using a filled square to indicate the color? And how to change the colors used with the goal to use more distinctive colors?
CodePudding user response:
Solution 1
Using this question as reference
Solution 2