Holen Sie sich Knotentext innerhalb des ausgefüllten Bereichs in Tikz

Holen Sie sich Knotentext innerhalb des ausgefüllten Bereichs in Tikz

Ich habe diese Figur gemacht

Bildbeschreibung hier eingeben

aus diesem Code:

\documentclass[tikz]{standalone}

\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}[domain=-90:200, x=0.025cm, y=0.15cm]

\draw[->,very thick] (-100,0) -- (250,0) node[right] {$x$};
\draw[->,very thick] (0,0) -- (0,45) node[above] {$y$};

\foreach \x in {-4,...,10} {
    \draw (20*\x,0) -- (20*\x,-1);
}
\foreach \y in {0,...,45} {
    \draw (0,\y) -- (-1,\y);
}

\draw[color=blue] plot ({\x},{34}) node[right] {$MR = 34$};
\draw[color=red] plot ({\x},{0.0018*\x*\x-0.2*\x+10}) node[above] {$MC = 0.0018 Q^2-0.2 Q + 10$};

\fill[pattern color=green, pattern=north east lines, opacity=0.9] plot[domain=-72.5840284:183.69514] ({\x},{0.0018*\x*\x-0.2*\x+10}) -- plot ({\x},{34}) -- cycle node {$DB$};

\end{tikzpicture}

\end{document}

Wie kann ich den Knoten mit Text DBin den ausgefüllten Bereich bringen? Wenn ich verwende, node[midway]befindet er sich über der Mitte der blauen Linie, aber ich möchte ihn genau in der Mitte des ausgefüllten grünen Bereichs haben.

Antwort1

Sie können path picturewie folgt verwenden:

\fill[pattern color=green, pattern=north east lines, opacity=0.9,path picture={
            \node[anchor=south]  at (path picture bounding box.center) {DB};
          }] plot[domain=-72.5840284:183.69514] ({\x},{0.0018*\x*\x-0.2*\x+10}) -- plot ({\x},{34}) -- cycle;

Code:

\documentclass[tikz]{standalone}

\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}[domain=-90:200, x=0.025cm, y=0.15cm]

\draw[->,very thick] (-100,0) -- (250,0) node[right] {$x$};
\draw[->,very thick] (0,0) -- (0,45) node[above] {$y$};

\foreach \x in {-4,...,10} {
    \draw (20*\x,0) -- (20*\x,-1);
}
\foreach \y in {0,...,45} {
    \draw (0,\y) -- (-1,\y);
}

\draw[color=blue] plot ({\x},{34}) node[right] {$MR = 34$};
\draw[color=red] plot ({\x},{0.0018*\x*\x-0.2*\x+10}) node[above] {$MC = 0.0018 Q^2-0.2 Q + 10$};

\fill[pattern color=green, pattern=north east lines, opacity=0.9,path picture={
            \node[anchor=south]  at (path picture bounding box.center) {DB};
          }] plot[domain=-72.5840284:183.69514] ({\x},{0.0018*\x*\x-0.2*\x+10}) -- plot ({\x},{34}) -- cycle;

\end{tikzpicture}

\end{document}

Bildbeschreibung hier eingeben

verwandte Informationen