5

I have a file with the points of a gaussian. I'm trying to paint the half of it (dividing it vertically). I'm using \pscustom but it keep painting the whole gaussian. What do you think the problem is?

Thank you very much.

\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
  • 1
    Could you post the data file so we can play with it?
    – Bernard
    Sep 24, 2016 at 23:31

3 Answers 3

4

I'm not sure whether you're required to use pstricks, but if not may I suggest taking a look at tikz-pgf. For example (I'm using a made-up data set, not yours):

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

produces

enter image description here

4

Like Derek's answer using tikz, but without using tables or scope.

\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}
1
  • 1
    This is what I would do, but I wasn't sure if the OP had true gaussian data, or some sort of approximation.
    – Derek
    Sep 25, 2016 at 2:01
3

pst-func has a function \psGauss. Here is a solution with some given values:

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

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .