TransWikia.com

How to configure axis on pgfplots?

TeX - LaTeX Asked by Regis Santos on January 28, 2021

How to configure axis on pgfplots? Similar for this.

documentclass{article}
usepackage{tikz,pgfplots}
pagestyle{empty}
begin{document}
begin{tikzpicture}[>=latex]
%x axis
draw[->] (-5,0) -- (5,0) node[below] {$x$};
foreach x in {-4,...,-1,1,2,...,4}
draw[shift={(x,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {footnotesize $x$};
%y axis
draw[->] (0,-5) -- (0,5) node[left] {$y$};
foreach y in {-4,...,-1,1,2,...,4}
draw[shift={(0,y)}] (2pt,0pt) -- (-2pt,0pt) node[left] {footnotesize $y$};
node[below left] at (0,0) {footnotesize $0$};
end{tikzpicture}
end{document}

enter image description here

One Answer

documentclass{article}
usepackage{tikz,pgfplots}
pagestyle{empty}
begin{document}
begin{tikzpicture}[>=latex]
begin{axis}[
  axis x line=center,
  axis y line=center,
  xtick={-5,-4,...,5},
  ytick={-5,-4,...,5},
  xlabel={$x$},
  ylabel={$y$},
  xlabel style={below right},
  ylabel style={above left},
  xmin=-5.5,
  xmax=5.5,
  ymin=-5.5,
  ymax=5.5]
addplot [mark=none,domain=-4:4] {x};
end{axis}
end{tikzpicture}
end{document}

enter image description here

Correct answer by Torbjørn T. on January 28, 2021

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