1

I'd like to put 4 x-axis on a same plot, with different scale. y-axis will be the same.

I'd try to put several \begin{axis} ... \end{axis}, but they appeared on the same location. Here, I tryed to put some fake x-axis, but it's pretty hard to do a good job.

If necessary, I can apply a factor on my data.

Does anybody have an idea to help me?

\documentclass[10pt]{article}

\usepackage{pgfplots}
\usepackage{subcaption}

\begin{document}

\begin{figure}[p]
\centering
    \begin{tikzpicture}
        \tikzstyle{every node}=[font=\small]
        \begin{axis}[height=0.8\textwidth,width=0.8\textwidth,
            axis lines=left, enlarge x limits=false,ymax=10,ymin=-0.08,
            xlabel={$x_1$},
            ylabel={$y$},
            legend entries={$x_1$,$x_2$,$x_3$,$x_4$},
            ]
            \addplot[draw=black,mark=o,line width=1.5pt] coordinates{(0,0)(2,2)(5,5)(8,8)(10,10)};

            \addplot[,draw=red,mark=star,line width=1.5pt] coordinates{(0,0)(5,3)(10,4)(20,7)(30,10)};

            \addplot[draw=blue,mark=square,line width=1.5pt] coordinates{(0,10)(10,6)(30,5)(60,3)(70,2)};

            \addplot[draw=green,mark=triangle,line width=1.5pt] coordinates{(0,7)(15,10)(30,7)(100,0)};
        \end{axis}

        \draw[->](0,-1.5)--(8,-1.5);
        \node[below] at (4,-1.5) {$x_2$};

        \draw[->](0,-2.5)--(8,-2.5);
        \node[below] at (4,-2.5) {$x_2$};

        \draw[->](0,-3.5)--(8,-3.5);
        \node[below] at (4,-3.5) {$x_2$};
    \end{tikzpicture}
\end{figure}
\vfill
\end{document}

output

2

I did the answer with the link controlling pgfplots axis labels (thank you Pier for the link) :

I post the corrected ECM for the forum :

            \documentclass[10pt]{article}

                        \usepackage{pgfplots}
                        \usepackage{subcaption}
                        \pgfplotsset{compat=1.10}

                        \begin{document}


            \begin{figure}[p]
            \centering
                \begin{tikzpicture}
                    \tikzstyle{every node}=[font=\small]
                    \begin{axis}[height=0.8\textwidth,width=0.8\textwidth,
            xlabel={$x_1$},
            ylabel={y},
            color=black,
            scale only axis,
            xmin=0,xmax=10,
            x axis line style={black},
            xtick style={black},
            xticklabel style={black},
            xtick={0,2,4,6,8,10},
            xticklabels={0,2,4,6,8,10},
            ymin=0,ymax=10,
            ytick={0,2,4,6,8,10},
            yticklabels={0,2,4,6,8,10},
            axis x line*=bottom,
            axis y line*=left,    
            tick align = outside]
            \addplot[draw=black,mark=o,line width=1.5pt] coordinates{(0,0)(2,2)(5,5)(8,8)(10,10)};
            \end{axis}

            \begin{axis}[height=0.8\textwidth,width=0.8\textwidth,
            xlabel={$x_2$},
            ylabel={y},
            color=red,
            scale only axis,
            xmin=0,xmax=30,
            x axis line style={red},
            xtick style={red},
            xticklabel style={red},
            xtick={0,5,10,15,20,25,30},
            xticklabels={0,5,10,15,20,25,30},
            ymin=0,ymax=10,
            ytick={0,2,4,6,8,10},
            yticklabels={0,2,4,6,8,10},
            hide y axis,
            axis x line*=bottom,
            axis y line*=none,    
            tick align = outside]
            \pgfplotsset{every outer x axis line/.style={yshift=-1.5cm}, every tick/.style={yshift=-1.5cm}, every x tick label/.style={yshift=-1.5cm} }
            \addplot[,draw=red,mark=star,line width=1.5pt] coordinates{(0,0)(5,3)(10,4)(20,7)(30,10)};
            \end{axis}


            \begin{axis}[height=0.8\textwidth,width=0.8\textwidth,
            xlabel={$x_3$},
            ylabel={y},
            color=blue,
            scale only axis,
            xmin=0,xmax=70,
            x axis line style={blue},
            xtick style={blue},
            xticklabel style={blue},
            xtick={0,20,40,60,80},
            xticklabels={0,20,40,60,80},
            ymin=0,ymax=10,
            ytick={0,2,4,6,8,10},
            yticklabels={0,2,4,6,8,10},
            hide y axis,
            axis x line*=bottom,
            axis y line*=none,    
            tick align = outside]
            \pgfplotsset{every outer x axis line/.style={yshift=-3cm}, every tick/.style={yshift=-3cm}, every x tick label/.style={yshift=-3cm} }
            \addplot[draw=blue,mark=square,line width=1.5pt] coordinates{(0,10)(10,6)(30,5)(60,3)(70,2)};
            \end{axis}


            \begin{axis}[height=0.8\textwidth,width=0.8\textwidth,
            xlabel={$x_4$},
            ylabel={y},
            color=green,
            scale only axis,
            xmin=0,xmax=100,
            x axis line style={green},
            xtick style={green},
            xticklabel style={green},
            xtick={0,20,40,60,80,100},
            ymin=0,ymax=10,
            ytick={0,2,4,6,8,10},
            hide y axis,
            axis x line*=bottom,
            axis y line*=none,    
            tick align = outside]
            \pgfplotsset{every outer x axis line/.style={yshift=-4.5cm}, every tick/.style={yshift=-4.5cm}, every x tick label/.style={yshift=-4.5cm}}
            \addplot[draw=green,mark=triangle,line width=1.5pt] coordinates{(0,7)(15,10)(30,7)(100,0)};
                        \end{axis} 

            \end{tikzpicture}
            \end{figure}

            \end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.