I have boxplots representing results of two methods, each with two validation approaches and three scenarios, to be plotted using ggplot2. Everything works fine, but I want to change the x-axis tick label to differentiate between the type of technique used in each group.
I used the following code:
data <- read.csv("results.csv", header = TRUE, sep=',')
ggplot() +
geom_boxplot(data = data, aes(x = Validation, y = Accuracy, fill = Scenario)) +
facet_wrap(~ Method) +
labs(fill = "")
where the structure of my data is as follows:
Method Validation Scenario Accuracy
-------------------------------------------------------
Method 1 Iterations Scenario 1 0.90
Method 1 Iterations Scenario 2 0.80
Method 1 Iterations Scenario 3 0.86
Method 1 Recursive Scenario 2 0.82
Method 2 Iterations Scenario 1 0.69
Method 2 Recursive Scenario 3 0.75
and got the following plot:
I just want to change the first x-tick label (Iterations) in Method 1 and Method 2 into 100-iterations and 10-iterations, respectively.
I tried to add this code but that changes the labels for both groups.
+ scale_x_discrete(name = "Validation",
labels = c("100-iterations", "Recursive",
"10-iterations", "Recursive")) +
Thanks in advance.