tikzpicture를 사용하여 영역을 음영 처리하고 그리는 방법은 무엇입니까?

tikzpicture를 사용하여 영역을 음영 처리하고 그리는 방법은 무엇입니까?

그래프 중앙에 있는 두 개의 굵은 선 사이의 영역을 음영 처리하려고 합니다. 지금까지의 진행 상황은 다음과 같습니다.

\documentclass[10pt,a4paper]{article}
\usepackage[spanish]{babel}
\usepackage[margin=1.27cm]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm, bm}
\usepackage{pgfplots}
\usepackage{float}
\usepackage{multicol}
\usepackage{bigints}
\usepackage{fullpage}
\usepackage{tikz}
\usepackage{caption}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{subcaption}


\begin{document}

\begin{figure}[H]
\centering
\caption*{Bounds for a Call option}
\par
\begin{tikzpicture}
\draw[thick] (0,4) node[left=2pt] {$C_t$} -- (0,0) ;
\draw[thick] (0,0) node[left=2pt] {0} -- (4,0) node[below=2pt] {$S_t$} node[right=2pt] {};
\draw[thick] (0,0) node[left=2pt] {0} -- (2,0) node[below=2pt] {$\frac{X}{R_f}$} node[right=2pt] {};
\draw[line width=1mm] (0,0) -- (2,0);
\draw[line width=1mm] (2,0) -- (4,4);
\draw[line width=1mm] (0,0) -- (2,4);
\draw(2,2) node{$C_t$} ;
\end{tikzpicture}
\end{figure}

\end{document}

감사합니다!

답변1

세 개의 굵은 선을 하나의 경로로 결합하고 키를 추가하기만 하면 됩니다 fill=<color>. 이는 선 결합이 보기 좋게 보인다는 추가적인 이점이 있습니다. (이것은 축의 경우에도 마찬가지입니다. 전체적으로 두 개의 경로만 필요합니다.)

\documentclass[10pt,a4paper]{article}
\usepackage[spanish]{babel}
\usepackage[margin=1.27cm]{geometry}
\usepackage{tikz}

\begin{document}

\begin{figure}[htb]
\centering
\caption*{Bounds for a Call option}
\par
\begin{tikzpicture}
\draw[thick] (0,4) node[left=2pt] {$C_t$} -- (0,0) 
 node[left=2pt] {0} -- node[below=2pt] {$\frac{X}{R_f}$} (4,0) node[below=2pt] {$S_t$};
\draw[line width=1mm,fill=gray!42] (2,4) -- (0,0) -- (2,0) -- (4,4)
 (2,2) node{$C_t$} ;
\end{tikzpicture}
\end{figure}
\end{document}

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

라인 조인을 변경할 수도 있습니다. 뻔뻔하게 광고하겠습니다.아이디어를 얻기 위한 최근 게시물입니다.. ;-) 예

  \draw[line width=1mm,fill=gray!42,line join=round,line cap=round] (2,4) -- (0,0) -- (2,0) -- (4,4) (2,2) node{$C_t$} ;

당신에게 준다

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

보시다시피 꽤 많은 패키지를 제거했습니다(하지만 babel간섭을 일으킬 수 있기 때문에 보관했으며 그렇지 않은지 확인하고 싶었습니다).

관련 정보