2

Hi i want to graphic the function: -2.5x^2+30x-50

if you search the equation in google:

enter image description here

but when i put it on latex:

enter image description here

The green curve is that equation and it is wrong

i use an escale: 1x10^{-3} is equal to 2 , just using the labels.

the code

\begin{tikzpicture}
\begin{axis}[ %inner axis line style={-latex},
width=15cm,height=6cm,
                axis x line=center,
                axis y line=center,
                xlabel={$t[s]$},ylabel={$v(t)[V]$},
                unit vector ratio*=2 1 1,
                xmin=-2,
                xmax=14,
                ymin=-5,
                ymax=5,
                xtick={2,4,6,8,10,12}, xticklabels={$1x10^{-3}$,$2x10^{-3}$,$3x10^{-3}$,$4x10^{-3}$,$5x10^{-3}$,$6x10^{-3}$},
                ytick={-2,2,4}, yticklabels={-20,20,40},
              ]


\draw[red!60,domain=0:2,samples=100,ultra thick]plot(\x,0.25*\x^2);
\draw[red!60,domain=0:2,ultra thick] plot[smooth] coordinates {(2,1)(4,3)};



\draw[green!60,samples=100,ultra thick]plot(\x^2,-2.5*\x^2+30*\x-50);
 \end{axis}
\end{tikzpicture}

Thanks .

  • 2
    Please make your question's title more accurate to the issue at hand. (make it searchable) – Jonathan Komar Apr 10 '17 at 6:39
6

You scaling seems wrong but I have no idea what units you were trying to use, which is why I simply rescaled them to your intended 2 -> 1e-3.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[
  /pgf/number format/sci generic={
    mantissa sep=\times,
    exponent={10^{#1}},
  }
  ]
  \begin{axis}[
    axis lines=center,
    tick scale binop=\times,
    scaled ticks=false,
    xlabel={$t[s]$},
    ylabel={$v(t)[V]$},
    xticklabel style={rotate=20},
    domain=0:6e-3,
    ]
    \addplot[red!60  ,samples=100,ultra thick] {0.25*(x*2e3)^2};
    \addplot[green!60,samples=100,ultra thick] {-2.5*(x*2e3)^2+30*(x*2e3)-50};
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

  • Thanks very much, i used that scale, because the original function was: -10000000x^2 +60000x-50 But appear an error: "Dimension too large" – Agu Nunes Apr 10 '17 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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