Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
2  
You need to elaborate on what you mean by "configure"? Do you want to have different labels than numeric values? Do you want to modify the spacing between elements? Or both? Do you want to modify the format of the labels? Do you want to modify the format of the ticks? Or both? Do you want to change the arrows on the axis? Do you want to add arrows? Or both? –  Werner Oct 12 '11 at 20:35
    
Do you mean something like the plot on page 169 of the version 1.5 manual for sine? –  Joseph Wright Oct 12 '11 at 20:35
add comment

1 Answer

up vote 8 down vote accepted
\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

share|improve this answer
    
Thanks Torbjorn T. –  Regis da Silva Oct 12 '11 at 21:29
4  
@RegisdaSilva We could still do with the question being clearer, for future users. –  Joseph Wright Oct 12 '11 at 21:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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