0

Im trying to plot the next equations:

y=10000+250x

y=50000-150x

But it plots the next way enter image description here

The MWE:

\documentclass[spanish]{beamer}
\usepackage[T1]{fontenc}
\usepackage[latin9]{luainputenc}
\usepackage{tikz}
\usepackage{subcaption}
\usepackage{pgfplots}
\usepackage{color}
\usepackage{amsmath}
\usetikzlibrary{decorations.pathreplacing}
\pgfplotsset{compat=1.14}

\begin{document}
\begin{frame}
\begin{tikzpicture}[scale=0.8]   
      \begin{axis}[
                    axis=equal,
                    axis lines = middle,
                    %xmin=0,xmax=40, ymin=0, ymax=5,
                    xlabel = $x$,
                    ylabel = {$f.g.$},
                    ]
                \addplot[smooth,dashed,fill=pink,opacity=0.5] {10000+250*x} node[below]{$f(x)$};
                \addplot[smooth,dashed,fill=pink,opacity=0.5] {50000-150*x} node[below]{$f(x)$};
                %\draw[fill=red] (axis cs:1,2) circle (0.1);
                \end{axis}    

    \end{tikzpicture}  
\end{frame}



\end{document}

When trying to adjust the axis options it simply does not plot the functions at all. This lines must be common in someplace in 40 or 350 but the axis dont adjust.

2
  • 3
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Commented Aug 23, 2021 at 23:10
  • 2
    Your example needs to be minimal to a to a certain extent. Please remove unused packages/code. See tex.meta.stackexchange.com/questions/228/… Commented Aug 23, 2021 at 23:18

4 Answers 4

4

You need to determine domain of your function. Also limits for functions should be consistent with its domain.

I guess that you are after something like this:

\documentclass[border=3.141592]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{intersections}

\begin{document}

    \begin{tikzpicture}[scale=0.8]
\begin{axis}[
    axis lines = middle,
    xmax=200, ymin=0,
    xlabel = $x$,
    ylabel = {$f.g.$},
    label style={anchor=north east},
    extra x ticks = {0},
    ytick={0,10 000,...,60 000},
    scaled y ticks=false,
    ticklabel style = {font=\footnotesize},
    yticklabel style={/pgf/number format/fixed},
    enlargelimits={0.15,upper},
%
    domain=0:200, no marks,
    every axis plot post/.append style={thick, dashed},
            ]
\addplot +[name path=A] {10000+250*x} node[right]{$f_1(x)$};
\addplot +[name path=B] {50000-150*x} node[right]{$f_2(x)$};
\fill [name intersections={of=A and B, by=a}]
       (a) circle[radius=2pt];
\end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

2

I have trouble understanding your question (language-wise) but maybe the following code helps.

\documentclass[tikz,border=1mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[
        width = 160mm,
        height = 90mm,
        axis lines = center,
        xmin = -0,
        xmax = 120,
        ymin = 0,
        ymax = 60000,
        enlarge x limits = 0.05,
        enlarge y limits = 0.10,
        ]
    \addplot[
        color = blue,
        mark = none,
        %smooth,
        line width = 1pt,
        domain = -10:120,
        ] {10000+250*x};     
        %  
    \addplot[
        color = red,
        mark = none,
        %smooth,
        line width = 1pt,
        domain = -10:120,
        ] {50000-150*x};     
        %        
    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

0
2
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}[scale=0.8]   
      \begin{axis}[
                    axis lines = middle,
                    xmin=0,xmax=200, ymin=0, ymax=60000,
                    xlabel = $x$,
                    ylabel = {$f.g.$},
                    ]
                \addplot[dashed, domain=0:190] {10000+250*x} node[below]{$f(x)$};
                \addplot[dashed, domain=0:190] {50000-150*x} node[below]{$f(x)$};
                \end{axis}    

\end{tikzpicture}  
\end{document}

Graph with crossing lines

2

Would this work for you (set domain=-1000:1000):

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{color}
\usepackage{amsmath}
\usetikzlibrary{decorations.pathreplacing}


\begin{document}
\begin{tikzpicture}
      \begin{axis}[domain=-1000:1000,
                    axis lines = middle,
                    xlabel = $x$,
                    ylabel = {$f.g.$},
                    ]
                \addplot[smooth,dashed,fill=pink,opacity=0.5] {10000+(250*x)} node[below]{$f(x)$};
                \addplot[smooth,dashed,fill=pink,opacity=0.5] {50000-(150*x)} node[below]{$f(x)$};
                \end{axis}    
    \end{tikzpicture}  

\end{document}

enter image description here

You must log in to answer this question.

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