After doing some research on this topic, I couldn't find an answer to this particular problem. I want to make a secondary x-axis but with categorical variables that repeat within intervals (but not repeating the same value over and over in the plot). A similar example of what I want can be seen in this picture (made with excel) :
The data:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
data1 = {'Month': list(range(11,35))+list(range(34,42)),
'Checkpoint': ['A','A','A','A','A','A','B','B','B','B','B','B','C','C','C','C','C','C','C','C','C','C','C','D','C','D','D','D','D','D','D','D'],
'Litres':[216545.67,18034.45,25807.83,46136.23,68099.21,55436.35,56412.33,9347.52,3177.29,103.89,333.29,2355.41,
49063.72,113622.80,243639.97,303992.32,255471.55,267022.75,274952.92,619665.39,798969.54,1127476.60,
1563344.98,1051827.75,603167.32,1880605.49,1931002.19,
2970500.68,2362336.66,5311058.83,5071784.10,5325575.47]}
df = pd.DataFrame(data1)
By running the code above, we obtain the following dataframe
Month Checkpoint Litres
0 11 A 216545.67
1 12 A 18034.45
2 13 A 25807.83
3 14 A 46136.23
4 15 A 68099.21
5 16 A 55436.35
6 17 B 56412.33
7 18 B 9347.52
8 19 B 3177.29
9 20 B 103.89
10 21 B 333.29
11 22 B 2355.41
12 23 C 49063.72
13 24 C 113622.80
14 25 C 243639.97
15 26 C 303992.32
16 27 C 255471.55
17 28 C 267022.75
18 29 C 274952.92
19 30 C 619665.39
20 31 C 798969.54
21 32 C 1127476.60
22 33 C 1563344.98
23 34 D 1051827.75
24 34 C 603167.32
25 35 D 1880605.49
26 36 D 1931002.19
27 37 D 2970500.68
28 38 D 2362336.66
29 39 D 5311058.83
30 40 D 5071784.10
31 41 D 5325575.47
I want to do a scatterplot (can be either with matplotlib or seaborn) of the data but with the 2nd x-axis (df['Checkpoint']).
plt.figure(figsize = (14,7))
plt.scatter(df['Month'], df['Litres'], s=30)