情节似乎不完整或根本没有

情节似乎不完整或根本没有

我正在尝试绘制下一个方程式:

y=10000+250x

y=50000-150x

但它计划接下来 在此处输入图片描述

妇女权利委员会:

\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}

当尝试调整轴选项时,它根本无法绘制函数。这些线在 40 或 350 中的某个地方肯定很常见,但轴没有调整。

答案1

您需要确定函数的定义域。函数的极限也应与其定义域一致。

我猜你正在追求这样的事情:

\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}

在此处输入图片描述

答案2

我无法理解您的问题(语言方面),但也许下面的代码有所帮助。

\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}

在此处输入图片描述

答案3

\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}

带有交叉线的图形

答案4

这对你有用吗(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}

在此处输入图片描述

相关内容