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 can I draw the x and y axis so that latex displays the tick numbers on it? (1 unit)

I try:

\begin{center}
\begin{tikzpicture}[scale=0.5]
\draw[very thick,blue] (3,-4) ellipse ({4} and {3});
\end{tikzpicture}
\end{center}
share|improve this question
3  
Could you please provide a compilable minimal working example (MWE) to work on? –  T. Verron Nov 10 '12 at 18:07
    
Were you able to solve your other problem of an inscribed square in an ellipse? –  Peter Grill Nov 10 '12 at 19:23
    
@Peter Grill: yeah, thanks! (it was easy) –  user10 Nov 10 '12 at 20:11
    
Ok that is good to know. Usually I would recommend not deleting a question as if one person made a mistake others will to at sometime. Also, in the future, please add a comment that you figured it out along with some explanation so those trying to help you can know, and then come back later to delete the question if you really think it is the right thing to do. –  Peter Grill Nov 10 '12 at 21:16

1 Answer 1

For most graphs I would recommend using pgfplots, but you can manually draw the axis and ticks with a \draw:

enter image description here

Notes:

  • If you want them drawn for each unit, then chnage the \foreach \x in {-1,1,...,8} to \foreach \x in {-1,...,8}, which will change the step size from 2 to 1.

Code:

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\tikzset{axis line style/.style={thin, gray, -stealth}}

\newcommand*{\TickSize}{2pt}%

\begin{document}
\begin{tikzpicture}[scale=0.5]
\draw[very thick,blue] (3,-4) ellipse ({4} and {3});

\draw [axis line style] (-2.5,0) -- (8.5,0);% x-axis
\draw [axis line style] (0,-8.5) -- (0,2.5);% y-axis

\foreach \x in {-1,1,...,8} {%
    \draw ($(\x,0) + (0,-\TickSize)$) -- ($(\x,0) + (0,\TickSize)$)
        node [above] {$\x$};
}

\foreach \y in {-7,-5,...,2} {%
    \draw ($(0,\y) + (-\TickSize,0)$) -- ($(0,\y) + (\TickSize,0)$)
        node [right] {$\y$};
}
\end{tikzpicture}
\end{document}
share|improve this answer

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.