I am wondering if it is possible to plot a graph where there would be two series of data, each with its different x axis. For example, I would like to produce something similar to that:
But so far, I only was able to plot this:
This is the code i used:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\usepackage{pgfplotstable, graphicx, tikz, float}
\usetikzlibrary{patterns}
\floatstyle{plaintop}
\newfloat{graphic}{thp}{lop}
\floatname{graphic}{\textsc{Graphique}}
\begin{document}
\pgfplotstableread[col sep=semicolon, header=true]{
periodes;ISF
nan;nan
;2.03200
1933-1937;2.19150
1938-1942;2.68000
1943-1947;3.11400
1948-1952;3.54250
1953-1957;3.60000
1958-1962;2.92750
1963-1967;2.32000
1968-1972;1.79800
1973-1977;1.80350
1978-1982;1.82700
1983-1987;2.02100
1988-1992;1.98250
1993-1997;2.01650
1998-2002;2.07300
2003-2007;1.95150
2008-2012;nan
}\loadedtable
\begin{graphic}[H]
\caption[position=above]{Comparaison ISF et DF}
\center
\begin{tikzpicture}[scale=.75]
\begin{axis}[
scale only axis,
ytick align=center,
ytick pos=left,
xtick align=center,
ymin=0,
xtick pos=left,
width=\textwidth,
height=10cm,
xlabel={\textit{Périodes}},
ylabel={\textit{ISF/DF}},
ymajorgrids,
xticklabels from table = {\loadedtable}{periodes},
xticklabel style={rotate=45,anchor =east, font=\tiny},
legend pos=outer north east,
]
\addplot table[x expr={\coordindex} ,y expr= {\thisrow{ISF}}] \loadedtable; \addlegendentry{ISF};
\end{axis}
\end{tikzpicture}
\end{graphic}
\end{document}
And let's say that my other series of data would be the following:
nan;nan
;2,50300
1916-1920;2,82650
1921-1925;3,07550
1926-1930;3,23000
1931-1935;2,98950
1936-1940;2,50300
1941-1945;2,13650
1946-1950;1,98550
1951-1955;1,99350
1956-1960;2,03850
1961-1965;nan
How can I make both appear on the same graph with a secondary X axis?
Thank you.