0

Have a plot diagram with x and y axis and i want to scale it such as stratching.

How do i do that?

\begin{tikzpicture}
\begin{axis}[
    axis lines = left,
    xlabel = $x$]
%Below the red parabola is defined

%Here the blue parabloa is defined
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {sin(deg(x))};
\label{$sin((x))$}
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {cos(deg(2*x))};
\addlegendentry{$cos(2x)$}
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {sin(deg(2*x))};
\addlegendentry{$sin(2x)$}
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {cos(deg(x))};
\addlegendentry{$cos(x)$}

\end{axis}
\end{tikzpicture}
  • Do not stretch the plot. Just use \pgfplotsset{width=...,height=...} to get the desired dimensions. You can also add width=...,height=... to the options of the axis. The problem is here, like in some of the questions before, that you do not provide a complete document. So it is hard to write an explicit answer. The choices depend on what you use in your document. – Schrödinger's cat Nov 12 at 1:52
0

The proper way to stretch a pgf plot is to increase its width. (Also, as Torbjørn T. told you, it is better to write \sin to typeset a sine function.)

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16} %<- you may want to add this

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    axis lines = left,
    xlabel = $x$]
%Below the red parabola is defined

%Here the blue parabloa is defined
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {sin(deg(x))};
\label{$sin((x))$} %<- dangerous practice
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {cos(deg(2*x))};
\addlegendentry{$\cos(2x)$}
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {sin(deg(2*x))};
\addlegendentry{$\sin(2x)$}
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {cos(deg(x))};
\addlegendentry{$\cos(x)$}

\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[width=0.9\textwidth,% <- added
    height=5cm,% <- added
    axis lines = left,
    xlabel = $x$]
%Below the red parabola is defined

%Here the blue parabloa is defined
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {sin(deg(x))};
\label{sin-2} %<- less dangerous 
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {cos(deg(2*x))};
\addlegendentry{$\cos(2x)$}
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {sin(deg(2*x))};
\addlegendentry{$\sin(2x)$}
\addplot [
    domain=0:9.5, 
    samples=700, 
    color=blue,
    ]
    {cos(deg(x))};
\addlegendentry{$\cos(x)$}

\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

As you can see, the second plot is "stretched" because the width was increased and the height decreased.

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.