TikZ/Pgf - Ich bekomme „Knoten“ nicht zum Laufen

TikZ/Pgf - Ich bekomme „Knoten“ nicht zum Laufen

Ich habe Probleme mit einer Arbeit und wäre für jede Hilfe dankbar. Ich möchte meinem Projekt folgenden Text hinzufügen:

Die roten Pfeile zeigen, was ich meine

Und hier ist mein Code, ich weiß nicht, warum node[left]{$P^*=50$}und node[below]{$Q^*=500$}nicht angezeigt

\begin{tikzpicture} 
\begin{axis} [axis lines = left, xlabel = $Q$, ylabel = {$P$}]

\addplot [domain=0:960, samples=100, color=green] {0.1*x} node [left] {$CMg$};
\addlegendentry{$0,1\cdot Q$};

\addplot [domain=0:1000, samples=100, color=red] {100-1/10*x} node [above right] {$IMg$};
\addlegendentry{$100-0,1\cdot Q$}

\draw [dashed] (0,50) node[left]{$P^*=50$} -- (500,50) -- (500,0) node[below]{$Q^*=500$};

\end{axis}
\end{tikzpicture}

Dank im Voraus!

Antwort1

Lassen Sie mich meinen Kommentar ausführlicher darlegen ... und einige kleine Änderungen an Ihrem Diagrammcode vornehmen. Vielleicht gefällt es Ihnen:

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}

\begin{document}
    \begin{tikzpicture}
\begin{axis}[
    axis lines = center, 
    xmax=1150, ymax=110,
    xlabel = $Q$, 
    ylabel = $P$,
    label style=right,
    legend style={at={(0.5,1)},legend columns=-1,
                  font=\scriptsize, anchor=north},
    legend cell align=left,
    samples=2, no marks,
    clip=false  % <---
            ]

\addplot +[domain=0:960] {0.1*x} node [right] {$CMg$};
\addplot +[domain=0:1000] {100-1/10*x} node [above right] {$IMg$};
\legend{${100-0,1{\cdot}Q}$,  ${0,1{\cdot}Q}$};

\draw[dashed]   (-2pt,   50) node[left, font=\footnotesize]{$P^*{=}50$} -| 
                (500,-2.5ex) node[below,font=\footnotesize]{$Q^*=500$};
\end{axis}
    \end{tikzpicture}
\end{document}

Bildbeschreibung hier eingeben

verwandte Informationen