tikz의 채워진 영역 내부에서 노드 텍스트 가져오기

tikz의 채워진 영역 내부에서 노드 텍스트 가져오기

이런 피규어를 만들었어요

여기에 이미지 설명을 입력하세요

이 코드에서:

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

DB채워진 영역 내부에 텍스트가 있는 노드를 얻는 것이 어떻게 가능합니까 ? 사용하면 node[midway]파란색 선의 중앙 위에 있지만 채워진 녹색 영역의 중앙에 정확히 있기를 원합니다.

답변1

path picture다음과 같이 사용할 수 있습니다 .

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

암호:

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

여기에 이미지 설명을 입력하세요

관련 정보