更改两个交叉点之间的线条颜色

更改两个交叉点之间的线条颜色

我正在尝试更改交叉点之间的线条颜色。我无法弄清楚如何使用 Intersection 包来实现此目的:

平均能量损失

\documentclass{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{10pt}%
%%%>

\usetikzlibrary{intersections}

\begin{document}


\begin{tikzpicture}[scale =1.3]
        \draw [step=.25,gray,very thin] (0,0)grid(5,5);
    
    
    \node [right] at (5.1,2.2) {\rotatebox{90}{\scriptsize Sense-Object $S$}};
    \node [below,left] at (2.8,-.3) {\scriptsize Sense-Object $R$};
    
    \node [align=right] at (5.6,4.8) {\scriptsize Origin for\\ \scriptsize Person $1$};
    \node [align=right] at (-.7,.7) {\scriptsize Origin for\\\scriptsize Person $2$};
    
    %initial endowment
    %\node [circle, fill=blue] at (2.5,3){};
    \fill[red] (.5,4.25) circle (1.5pt);
    
    \draw[red, thick, name path = A] plot [smooth] coordinates {(3.5,1.25)(3,2.47)(2.5,3.19)(2,3.62)(1.5,3.9)(1,4.105)(.5,4.25)};
    \draw[blue, thick, name path = B] plot [smooth] coordinates {(3.5,1.25)(1.55,2)(.84,3)(.55,4)(.5,4.25)};
   
   \path [name path=curve, draw=none]plot [smooth] coordinates {(3.5,1.25)(3,2.47)(2.5,3.19)(2,3.62)(1.5,3.9)(1,4.105)(.5,4.25)};
   
   
   \path [name path=curve2, draw=none]plot [smooth] coordinates {(3.5,1.25)(1.55,2)(.84,3)(.55,4)(.5,4.25)};
  
     \path [name path=curve3, draw=none]plot [smooth] coordinatesplot [smooth] coordinates {(5,5)(4.52,4.775)(4,4.5)(3.5,4.2)(3,3.85)(2.52,3.47)(2,3)(1.5,2.45)(1,1.8)(.5,1)(.0,0)};
     
     \path [name intersections={of = curve1 and curve3}];
  \coordinate (A)  at (intersection-1);
  
   \path [name intersections={of = curve2 and curve3}];

  \coordinate (B)  at (intersection-2);
     
     
     \draw [green, ultra thick] (A) -- (B);
     
     
       
    \tikzfillbetween[of=A and B]{blue, opacity=0.2};
    %%contract curve
  \draw[black, thick] plot [smooth] coordinates {(5,5)(4.52,4.775)(4,4.5)(3.5,4.2)(3,3.85)(2.52,3.47)(2,3)(1.5,2.45)(1,1.8)(.5,1)(.0,0)};

    %\path[green, thick, name interesections={of=A and B] 
    
    \end{tikzpicture}

\end{document} 

这

这是我的输出。我希望从黑线与蓝线相交处到黑线与蓝线相交处有一条粗绿线。

答案1

您可以找到交点并重新绘制由交点定义的矩形所剪裁的黑线。

\documentclass{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{10pt}%
%%%>

\usetikzlibrary{intersections}

\begin{document}


\begin{tikzpicture}[scale =1.3]

    \draw [step=.25,gray,very thin] (0,0)grid(5,5);
       
    \node [right] at (5.1,2.2) {\rotatebox{90}{\scriptsize Sense-Object $S$}};
    \node [below,left] at (2.8,-.3) {\scriptsize Sense-Object $R$};
    
    \node [align=right] at (5.6,4.8) {\scriptsize Origin for\\ \scriptsize Person $1$};
    \node [align=right] at (-.7,.7) {\scriptsize Origin for\\\scriptsize Person $2$};
    
    %initial endowment
    %\node [circle, fill=blue] at (2.5,3){};
    \fill[red] (.5,4.25) circle (1.5pt);
    
    \draw[red, thick, name path = A] plot [smooth] coordinates {(3.5,1.25)(3,2.47)(2.5,3.19)(2,3.62)(1.5,3.9)(1,4.105)(.5,4.25)};

    \draw[blue, thick, name path = B] plot [smooth] coordinates {(3.5,1.25)(1.55,2)(.84,3)(.55,4)(.5,4.25)};
   
%    %%contract curve
  \draw[black, thick, name path=contract] plot [smooth] coordinates {(5,5)(4.52,4.775)(4,4.5)(3.5,4.2)(3,3.85)(2.52,3.47)(2,3)(1.5,2.45)(1,1.8)(.5,1)(.0,0)};

     \path [name intersections={of = A and contract, name=Acontract}];
     \path [name intersections={of = B and contract, name=Bcontract}];
     
    \begin{scope}
    \clip (Acontract-1) rectangle (Bcontract-1);
  \draw[green, line width=1mm] plot [smooth] coordinates {(5,5)(4.52,4.775)(4,4.5)(3.5,4.2)(3,3.85)(2.52,3.47)(2,3)(1.5,2.45)(1,1.8)(.5,1)(.0,0)};
    \end{scope}
    \end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容