TransWikia.com

Different xtick distance for different x ranges

TeX - LaTeX Asked by user94758 on December 26, 2020

I created a graph using tikz, which ranges from -10 to 10 for the xaxis.

The graph has an xtick distance of 2, but I want to change the xtick distance so I get this: -10,-5,0,2...10.
From -10 to 0, I want steps of 5, and from 0 to 10, I want steps of 2.

Is this possible to do?

I have added my code as well.

begin{figure}[!htb]
    centering
    begin{tikzpicture}
    begin{axis}[xmin=-10, xmax = 10,ymin=0,
    xtick distance=2,
    xlabel=$x$,ylabel=$Error$,
    title = {Output Error},
    ]
    addplot [mark=none,color=orange] table[x=x,y=error,col sep=comma]{./output_error.csv};         
    end{axis}
    end{tikzpicture}
end{figure}

enter image description here

One Answer

Welcome to TeX-SE! You can just punch in what you want to get: xtick={-10,-5,0,2,4,...,10}. Obviously I do not have your data file.

documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
    begin{tikzpicture}
    begin{axis}[xmin=-10, xmax = 10,ymin=0,
    xtick={-10,-5,0,2,4,...,10},
    xlabel=$x$,ylabel=Error,
    title = {Output Error},
    ]
    addplot [mark=none,color=orange] {x};
    %table[x=x,y=error,col sep=comma]{./output_error.csv};         
    end{axis}
    end{tikzpicture}
end{document}

output plot

Correct answer by user121799 on December 26, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP