I have created the a chart in ggplot2 using the data shown here:
  Categories       A1       A2       A3       A4       A5
1       XX_1   41.151   61.017   67.639     94.6  137.643
2       XX_2  93.4175 127.4735    141.9  153.252  180.213
3       YY_1 160.5835  169.807  166.969 169.5705   184.47
4       YY_2  171.226 184.7065 194.1665 187.0715  218.526
5       ZZ_1  83.4845   97.438   122.98 127.4735 140.7175
6       ZZ_2 126.5275  139.535  140.954  157.982  183.524
8       LL_1   81.829   72.842  67.8755    56.76   48.246
9       LL_2   58.652   52.976  41.8605   32.164  31.9275
As you can see in the data that there are three sets of similar categories—XX, YY, ZZ, LL. These categories also have two sub-division-- _1 and _2. When I plot the data, all the categories are plotted equidistant from each other as shown in the chart here
However, I want the similar categories like LL_1 and LL_2 to be closer to each other, and the space between different pairs like XX , ZZ, YY, and YY to increase. I don't want all the categories to be equidistant from each other. I want to custom change the distance of similar and dissimilar categories. As shown in a rough Chart1 here:
I also don't want to use facet_wrap, and would like all the data to be shown in the same chart. I would really appreciate if someone could guide on how to solve this problem.
Below is the code i used to plot the chart:
##Loading the excel data
df <- read_excel("~\Sample.xlsx")
##Converting from wide to long format
df1 <- melt(df, id.vars = "Categories", measure.vars = c("A1", "A2", "A3", "A4", "A5"), variable.name = "AA", value.name = "values")
df1 <- df1[order(df1$Categories), ]
##Plotting the data
p6 <- ggplot(data = df1, mapping = aes(x=values, y=Categories))
p6 + geom_line(color="brown", size=0.1)+ geom_point(aes(color=AA), size=0.5)+
  theme(axis.title.y = element_blank(), axis.text = element_text(face = "bold"),axis.text.y = element_text(size = 2.2),
        axis.text.x = element_text(size = 2.2), axis.title.x = element_text(size = 2.5), axis.line.x = element_line(size = 0.2), axis.line.y = element_line(size = 0.2),
        axis.ticks = element_line(size = 0.2),axis.ticks.length = unit(0.03, "cm"),
        legend.key = element_blank(), legend.spacing.y = unit(0.05, "cm"), legend.key.size = unit(0.2, "cm"),
        legend.title = element_text(face = "bold", size = 2.5),legend.text = element_text(size = 2), panel.background = element_blank(), panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"), panel.border = element_blank())+ 
  scale_x_continuous(breaks=seq(0,220,5))+
  labs(x="Number", color="Category")
Thanks


 
    
 
    
