How to increase tick spacing for similar categories and reduce the spacing for dissimilar categories on the same axis?


I have created the following chart in ggplot2 using the following data.

Categories A1 A2 A3 A4 A5
XX_1 41.151 61.017 67.639 94.6 137.643
XX_2 93.4175 127.4735 141.9 153.252 180.213
YY_1 160.5835 169.807 166.969 169.5705 184.47
YY_2 171.226 184.7065 194.1665 187.0715 218.526
ZZ_1 83.4845 97.438 122.98 127.4735 140.7175
ZZ_2 126.5275 139.535 140.954 157.982 183.524
LL_1 81.829 72.842 67.8755 56.76 48.246
LL_2 58.652 52.976 41.8605 32.164 31.9275

As you can see 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 below.

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.

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.


The following chart shows (roughly), how i want my new chart to look like.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.