5

I have the following problem:

\begin{center}
\begin{tikzpicture}[scale=0.5, >=latex]
\draw[->] (-6,0) -- (6,0) node[right] {\scriptsize $x$};
\draw[->] (0,-5) -- (0,15) node[above] {\scriptsize $y$};
\foreach \x in {-5,...,5} \draw (\x, 1pt) -- (\x,-3pt) node[anchor=north] {\tiny \x};
\foreach \y in {-4,-2,...,14} \draw (1pt,\y) -- (-3pt,\y) node[anchor=east] {\tiny \y};
\draw[color=black, thick, domain=-0.8:3.8, samples=100]   plot (\x,{-3*(\x)^2+9*(\x)+6}) node[right] {\tiny $f(x)$};
\end{tikzpicture}
\end{center}

I want the y Axis to be smaller like the xAxis. How can I achieve this?

enter image description here

2
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Commented Oct 6, 2014 at 20:49
  • Try [scale=0.5, >=latex, y=.5cm].
    – Tarass
    Commented Oct 6, 2014 at 20:56

2 Answers 2

6

Leave it to pgfplots or use TikZ' datavisualization library;

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,xlabel=$x$,ylabel=$y$,enlargelimits]
\addplot[domain=-1:4] {-3*x^2+9*x+6} node[left]{$f(x)$};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

0

Substituting the lines 6-7 with:

\foreach \y [evaluate=\y as \sy using \y/2] in {-4,-2,...,14} \draw (1pt,\sy) -- (-3pt,\sy) node[anchor=east] {\tiny \y};
\draw[color=black, thick, domain=-0.8:3.8, samples=100]   plot (\x,{(-3*(\x)^2+9*(\x)+6)/2}) node[right] {\tiny $f(x)$};

should work as expected.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .