在曲线之间绘画

在曲线之间绘画

我有一个包含高斯点的文件。我试图绘制它的一半(垂直划分)。我正在使用 \pscustom,但它继续绘制整个高斯。你认为问题是什么?

非常感谢。

\documentclass[crop=true]{standalone} 
\usepackage{pst-plot}
\usepackage{pstricks-add}
\usepackage{pst-func,animate}
\pagestyle{empty}

\readdata{\dataGauss}{dataGauss.txt}


\begin{document}
\begin{pspicture}(-1,0)(16,7.6)

\pscustom[linestyle=none,fillstyle=solid,fillcolor=red]{
\listplot[linewidth=0.04, linecolor=blue]{\dataGauss}
\psplot[linewidth=0pt,plotpoints=500,linecolor=black] {3.5}{7.5}{ 0 }}


\end{pspicture}
\end{document}

答案1

我不确定您是否需要使用 pstricks,但如果不需要,我建议您查看一下tikz-pgf。例如(我使用的是虚构的数据集,不是您的):

\documentclass[border = 0.2in]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale = 2]
  \begin{scope}
    \clip (-2, -0.2) rectangle (0, 1.2);
    \path [fill = lightgray]
      plot [mark = x, smooth] file {gauss.table};
  \end{scope}
  \draw [thick]
    plot [mark = x, smooth] file {gauss.table};
\end{tikzpicture}
\end{document}

生产

在此处输入图片描述

答案2

类似于 Derek 使用 tikz 的答案,但不使用表格或范围。

\documentclass[border = 0.2in]{standalone}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}[scale = 2]
    \fill [LightGray,domain=-2:0,samples=200]  plot (\x,{exp(-2*\x*\x)}) -- (0,0) -- (-2,0) -- cycle;
    \draw [thick,domain=-2:2,samples=200] plot (\x,{exp(-2*\x*\x)});
    \end{tikzpicture}
\end{document}

答案3

pst-func有一个函数\psGauss。以下是具有一些给定值的解:

\documentclass[crop=true,pstricks]{standalone} 
\usepackage{pst-plot}
\usepackage{pst-func}
\pagestyle{empty}
\usepackage{filecontents}
\begin{filecontents*}{dataGauss.txt}
-4   0
-3.5 0.005
-3   0.01
-2.5 0.02
-2  0.05
-1.5 0.14
-1   0.245
-0.5 0.35
0   0.4
0.5 0.35
1  0.245
1.5 0.14
2 0.05
2.5 0.02
3 0.01
4 0
}
\end{filecontents*}

\readdata{\dataGauss}{dataGauss.txt}

\begin{document}
\psset{yunit=5}
\begin{pspicture}(-5,-0.1)(5,0.5)
\pscustom[fillstyle=solid,fillcolor=blue!40,linestyle=none]{%
  \listplot[xEnd=0,plotstyle=curve]{\dataGauss}
  \psline(0,0)(-2.9,0)}
\listplot[xStart=0,linecolor=blue,linestyle=dashed,plotstyle=curve]{\dataGauss}
\listplot[xEnd=0,linecolor=blue,plotstyle=curve]{\dataGauss}
\psaxes[ticks=none,labels=none]{->}(0,0)(-4.5,0)(4.5,0.45)
\end{pspicture}
\end{document}

在此处输入图片描述

相关内容