如何使用 pspicture 填充曲线之间的分隔空间

如何使用 pspicture 填充曲线之间的分隔空间

正如标题所说,我需要在不同的图形中填充一些空间(使用创建pspicture),但当空间不是由直线分隔时,我不知道该怎么做。在这种情况下,我使用\pspolygon,仅此而已。你能帮助我并教我怎么做吗?我需要在 4 或 5 个图形中做到这一点,我写下其中一个的代码。非常感谢所有能帮助我的人。这是代码:

\documentclass[12pt]{article}
\usepackage[usenames,dvipsnames]{pstricks}
\usepackage{epsfig}
\usepackage{pst-grad}
\usepackage{pst-plot}
\usepackage{color}
\usepackage[labelfont=bf,font=small,justification=justified]{caption}
\input{tcilatex}

\begin{document}

\begin{center}
\begin{pspicture}(3.7,-3.762997)(10.56794,8.762997)

%COLORES
\definecolor{colour0}{rgb}{0.2,0.2,1.0} %Azul
\definecolor{colour1}{rgb}{1.0,0.0,0.2} %Rojo
\definecolor{colour2}{rgb}{0.8,0.8,0.8} %Gris claro (linea punteada)
\definecolor{colour3}{rgb}{0.0,0.2,1.0} %Azul
\definecolor{colour4}{rgb}{0.2,0.6,0.0} %Verde
\definecolor{bubblegum}{rgb}{0.99, 0.76, 0.8}
%Además, se usan colores:
%MidnightBlue: Curva IC
%LimeGreen: Curva PC
%Black: Ejes
%Gray: Región de soluciones

%EJES
%Vertical
\psline[linecolor=black, linewidth=0.03,  arrowsize=0.05291666666666667cm 2.0,arrowlength=1.4,arrowinset=0.0]{->}(0.810012,-1.6741458)(0.810012,9.125854)
%Horizontal
\psline[linecolor=black, linewidth=0.03, arrowsize=0.05291666666666667cm 2.0,arrowlength=1.4,arrowinset=0.0]{->}(0.810012,-1.6741458)(11.110012,-1.6741458)

%SOLUCION FACTIBLE
%Region de soluciones
%\pspolygon[linecolor=colour2, linewidth=0.02, fillstyle=solid,fillcolor=colour2, opacity=0.3](3.2,3.39)(0.838,5.17)(0.838,8.47)(9.710012,8.4741458)

%CURVAS
%Curva LLC
%Vertical
%\psline[linecolor=bubblegum, linewidth=0.02, linestyle=dashed](0.835, -1.65)(0.835, 8.95)
%Horizontal
%\psline[linecolor=bubblegum, linewidth=0.02, linestyle=dashed](0.84,-1.65)(10.85,-1.65)
%Curva IC
\psbezier[linecolor=MidnightBlue, linewidth=0.05](0.8, 2)(5, 3.8)(7, 6)(8.6, 8.5)
%Curva PC
\psbezier[linecolor=LimeGreen, linewidth=0.05](0.83, 6)(1.5, 3.9)(5.655, -0.6)(9.65, -1.67)
%Curva Isocosto
\psline[linecolor=LimeGreen, linewidth=0.05](1.2, 3.6)(4.5, 2.35)
\psline[linecolor=LimeGreen, linewidth=0.05](3.4, 1.5)(6.8, 0.212121214)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](1.3, 3.55)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](1.7, 3.41)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](2.1, 3.26)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](2.5, 3.1)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](2.9, 2.95)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](3.3, 2.81)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](3.7, 2.65)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](4.1, 2.49)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](4.5, 2.357)
%\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.2](5, 1.95)
%\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.2](5.5, 1.55)
%\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.2](6, 1.15)
%\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.2](6.5, 0.75)
%\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.2](7, 0.4)
%\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.2](7.5, 0.0)
%\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.2](8, -0.4)
%\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.2](8.5, -0.8)
%\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.2](9, -1.2)
%\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.2](9.5, -1.55)
%Optimal Incentive S.
%\psline[linecolor=bubblegum, linewidth=0.05](3.21, 3.33)(0.8,5.2)


%TEXTO AGREGADO (Números, Letras, etc)
%Horizontales
\rput[bl](2.67, -2.2076814){$w^{k}_{\scriptscriptstyle{F}}$}
\rput[bl](4.9, -2.2076814){$w^{t}_{\scriptscriptstyle{F}}$}
\rput[bl](9.1, -2.7){$\left[\frac{\underline{U}}{1-p}\right]^{\frac{1}{1-\gamma}}$}

%Verticales
\rput[bl](-0.5, 1.75){$\left[\frac{B}{p}\right]^{\frac{1}{1-\gamma}}$}
\rput[bl](0.13, 2.9){$w^{*}_{\scriptscriptstyle{E}}$}
\rput[bl](-0.5, 5.75){$\left[\frac{\underline{U}}{p}\right]^{\frac{1}{1-\gamma}}$}

%Básicas
\rput[bl](0.5, -2.1076814){$0$}
\rput[bl](10.99,-2.2076814){$w_{\scriptscriptstyle{F}}$}
\rput[bl](0.13,8.7){$w_{\scriptscriptstyle{E}}$}
\rput[bl](5.1, 3.2){$(w^{*}_{\scriptstyle{F}},w^{*}_{\scriptstyle{E}})$}


%Interseccion UNO
\psdots[linecolor=black, dotsize=0.1](2.81, 2.99)
%Línea horizontal punteada de intersección
\psline[linecolor=black, linewidth=0.0, linestyle=dashed, dash=0.18cm 0.11cm](0.810012, 2.99)(2.82, 2.99)
%Línea vertical punteada de intersección
\psline[linecolor=black, linewidth=0.0, linestyle=dashed, dash=0.18cm 0.11cm](2.81, -1.6741458)(2.81, 2.99)
%Flecha
\psline[linecolor=black, linewidth=0.02,  arrowsize=0.05cm 2.0, arrowlength=1.4, arrowinset=0.0]{->}(2.81, 2.99)(5, 3.4)

%Interseccion DOS
\psdots[linecolor=black, dotsize=0.1](5.07, 0.86)
%Línea vertical punteada de intersección
\psline[linecolor=black, linewidth=0.0, linestyle=dashed, dash=0.18cm 0.11cm](5.07, -1.6741458)(5.07, 0.85)

%LEYENDA
\psframe[linecolor=black, linewidth=0.01, fillstyle=solid, dimen=outer](16.070012,2.5)(10.110012,5.35)
%Referencia gráfica
%Optimal Incentive S.
%\psline[linecolor=bubblegum,linewidth=0.05](10.480012, 5.3858546)(11.1133455, 5.3858546)%1
%PC (binding)
\psline[linecolor=LimeGreen, linewidth=0.05](10.480012,4.85)(11.1133455,4.85)%2
%IC (binding)
\psline[linecolor=MidnightBlue, linewidth=0.05](10.480012,4.395854)(11.1133455,4.395854)%3
%LLC (binding)
\psline[linecolor=bubblegum, linewidth=0.05, linestyle=dashed, dash=0.13638889cm 0.10583334cm](10.480012,3.88)(11.1133455,3.88)%4
%Isocost %5
\psline[linecolor=LimeGreen, linewidth=0.05, 0.10583334cm](10.480012,3.45)(11.1133455,3.45)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](10.52, 3.45)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](10.80, 3.45)
\psdots[linecolor=black,fillcolor=white, dotstyle=o, dotsize=0.15](11.08, 3.45)
%Region solutions
\pspolygon[linecolor=gray, linewidth=0.02, fillstyle=solid,fillcolor=colour2, opacity=0.3](10.4, 2.85)(11.25, 2.85)(11.25, 3.05)(10.4, 3.05)%6

%Texto
%\rput[bl](11.4733574, 5.2191876){\footnotesize : Optimal Incentive Scheme}%1
\rput[bl](11.4733574, 4.7191875){\footnotesize : PC (binding)}%2
\rput[bl](11.4733574, 4.2191876){\footnotesize : IC (binding)}%3
\rput[bl](11.4733574, 3.7191876){\footnotesize : LLC (binding)}%4
\rput[bl](11.4733574, 3.34){\footnotesize : Isocost}%5
\rput[bl](11.4733574, 2.8){\footnotesize : Region of feasible solutions}%6

\end{pspicture}
\end{center}

{\footnotesize \textbf{Figure 8.} Linear incentives, risk aversion & limited liability.}

\end{document}

我需要用纯色灰色填充空间,在下图中,我用红线突出显示了该区域。此外,包围空间的曲线也写在第 45 和 47 行在此处输入图片描述

再次感谢,我确实需要这样做,但我甚至不知道如何开始 :/

答案1

我使用正则表达式搜索和替换将大部分 PSTricks 代码转换为 TiZ,但远非完美。虽然我相信你可以在 PSTricks 中做到这一点(如果\pscustom我没记错的话),但你可能只需切换到 Ti使用 Z 确实很容易。

\documentclass[12pt]{article}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{patterns.meta} 
\pgfdeclarepattern{
name=xhatch, parameters={\hatchsize,\hatchangle,\hatchlinewidth}, 
bottom left={\pgfpoint{-.1pt}{-.1pt}},
top right={\pgfpoint{\hatchsize+.1pt}{\hatchsize+.1pt}}, tile size={\pgfpoint{\hatchsize}{\hatchsize}},
tile transformation={\pgftransformrotate{\hatchangle}}, code={
\pgfsetlinewidth{\hatchlinewidth} 
\pgfpathmoveto{\pgfpoint{-.1pt}{\hatchsize/2}} 
\pgfpathlineto{\pgfpoint{\hatchsize+.1pt}{\hatchsize/2}} 
\pgfpathmoveto{\pgfpoint{\hatchsize/2}{-.1pt}} 
\pgfpathlineto{\pgfpoint{\hatchsize/2}{\hatchsize+.1pt}} 
\pgfusepath{stroke}
} }
\tikzset{
hatch size/.store in=\hatchsize,
hatch angle/.store in=\hatchangle,
hatch line width/.store in=\hatchlinewidth, 
hatch size=5pt,
hatch angle=45,
hatch line width=.5pt,
}

\usepackage[labelfont=bf,font=small,justification=justified]{caption}
%\input{tcilatex}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[area/.style={pattern=xhatch,pattern color=red}]

%COLORES
\definecolor{bubblegum}{rgb}{0.99, 0.76, 0.8}
\begin{scope}
 \clip (0.8,8.5) --
 (0.8, 2) .. controls (5, 3.8) and (7, 6) .. (8.6, 8.5) |- cycle;
 \path[area] (0.8,8.5) --
 (0.83, 6) .. controls (1.5, 3.9) and (5.655, -0.6) .. (9.65, -1.67) |- cycle;
\end{scope}

\draw[semithick,stealth-stealth]
    (0.810012,9.125854) node[below left] {$w_{\scriptscriptstyle{E}}$} 
    |- (11.110012,-1.6741458)   node[below] {$w_{\scriptscriptstyle{F}}$}
    node[pos=0.5,below left]{$0$};
\draw[MidnightBlue,thick] 
    (0.8, 2) .. controls (5, 3.8) and (7, 6) .. (8.6, 8.5);
\draw[LimeGreen,thick]  
    (0.83, 6) .. controls (1.5, 3.9) and (5.655, -0.6) .. (9.65, -1.67)
    (1.2, 3.6)--(4.5, 2.35)
    (3.4, 1.5)--(6.8, 0.212121214);
\draw plot[only marks,mark=*,mark options={fill=white,draw},mark size=2pt] 
   coordinates 
    {(1.3, 3.55)(1.7, 3.41)(2.1, 3.26)(2.5, 3.1)(2.9, 2.95)(3.3, 2.81)(3.7, 2.65)(4.1, 2.49)(4.5, 2.357)};
\path 
(0.8, 2) node[left] {$\left[\frac{\underline{B}}{p}\right]^{\frac{1}{1-\gamma}}$}
(0.83, 6) node[left] {$\left[\frac{\underline{U}}{p}\right]^{\frac{1}{1-\gamma}}$}
(9.65, -1.67) node[below] {$\left[\frac{\underline{U}}{1-p}\right]^{\frac{1}{1-\gamma}}$};  

\draw[dashed] (0.810012, 2.99) node[left] {$w^{*}_{\scriptscriptstyle{E}}$} -| (2.81, -1.6741458)
 node[below]{$w^{k}_{\scriptscriptstyle{F}}$}
 (5.07, -1.6741458)  node[below]{$w^{t}_{\scriptscriptstyle{F}}$} -- (5.07, 0.85);

\path (11,5) node[matrix,draw]{
 \draw[thick,bubblegum] (0,0) -- (2em,0) node[right] {PC (binding)};\\
 \draw[thick,LimeGreen] (0,0) -- (2em,0) node[right] {IC (binding)};\\
 \draw[thick,MidnightBlue] (0,0) -- (2em,0) node[right] {LLC (binding)};\\
 \draw plot[mark=*,mark options={fill=white,draw},mark size=2pt] 
  coordinates {(1pt,0) (1em,0) (2em-1pt,0)} (2em,0) node[right] {Isocost};\\
 \draw[area] (0,-1ex) rectangle (2em,1ex)
 (2em,0) node[right]{Region solutions}; \\
};
\end{tikzpicture}
\caption{Linear incentives, risk aversion \& limited liability.}
\end{figure}
\end{document}

在此处输入图片描述

area/.style={fill=gray!20}

它成为了

在此处输入图片描述

答案2

我看你是用软件画的吧!

以下代码有效:

...
%LimeGreen: Curva PC
%Black: Ejes
%Gray: Región de soluciones

\psclip{
    \pscustom[linestyle=none]{
        \psbezier(0.8, 2)(5, 3.8)(7, 6)(8.6, 8.5)
        \psline(8.6,8.5)(0,8.5)
        \psline(0,8.5)(0.83, 6)
        \psbezier(0.83, 6)(1.5, 3.9)(5.655, -0.6)(9.65, -1.67)
}}
\psframe[fillstyle=solid,fillcolor=gray](0.810012,-1.6741458)(9,9.125854)
% or \psframe[fillstyle=vlines](0.810012,-1.6741458)(9,9.125854)
\endpsclip
\psframe[fillstyle=solid,fillcolor=white,linestyle=none](0.8, -1.5)(9.13, 2.955)

%EJES
%Vertical
...

在此处输入图片描述

相关内容