3

Look at the following MWE which is compiled via latex->dvips->ps2pdf

\PassOptionsToPackage{dvipsnames,table}{xcolor}
\documentclass[pstricks,border=0pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{datatool}
\usepackage[gray]{databar}
\usepackage{xcolor}  
\usepackage{pst-plot} 
\usepackage{pst-func}
\usepackage{pst-blur}
\usepackage{pst-lens} 
\usepackage{pst-intersect}
\usepackage{pstricks-add} 


 \xdefinecolor{dunkelgrau}{rgb}{0.8,0.8,0.8}
 \xdefinecolor{hellgrau}{rgb}{0.95,0.95,0.95}

\providecommand{\mytext}{}

\providecommand{\gengini}[6]{%
\newpage%
\FPupn{fra}{#1}%
\pstVerb{/ra \fra\space def}%
\FPupn{frb}{#2}%
\pstVerb{/rb \frb\space def}%
\FPupn{frc}{#3}%
\pstVerb{/rc \frc\space def}%
\FPupn{frd}{#4}%
\pstVerb{/rd \frd\space def}%
\FPupn{fre}{#5}%
\pstVerb{/re \fre\space def}%
\FPupn{frf}{#6}%
\psset{lly=-13mm,llx=-9mm,urx=25mm,ury=15mm}%
\psgraph[xAxisLabel={\ },yAxisLabel={\ },Ox=0,Dx=20,Dy=0.2,dx=0.2](-0.0,-0.0)(1,1){6cm}{6cm}%
 \psclip{%
 \pscustom[linestyle=none,fillstyle=solid,fillcolor=red]{%
     \psLorenz[plotstyle=bezier,linecolor=black,liftpen=2]{0.025 0.2 0.21 0.27 0.295}%
     \psLorenz[plotstyle=bezier,linecolor=black,liftpen=2]{ra rb rc rd re}%
     }%
    }%
\endpsclip%
\endpsgraph%
}%


\begin{document}
\gengini{0.00135847}{0.00411338}{0.00163124}{0.00079123}{0.99210568}{1}%   

\end{document}

Goal: Fill with color (or other fill-styles) between two psLorenz curves. Attention: It is required not to subtract areas, because this piece of code is part of other code, too... which is not part of the problem and therefore removed.

I have tried to solve this problem but it seems to me that I am not able to connect the endpoints together.

Update: Goal: Red between both pslorenz. No Fill between lorenz and a simple line

3
  • Could you upload a screenshot of what you have and be a bit more specific on your problems. If I compile your MWE, I see a red area between a straight line and a curve. It would be easier if you explain a bit than us having to decipher your source code.
    – LaRiFaRi
    Jul 20 '15 at 7:55
  • And please minimize your code. \usepackage{filecontents} is unnecessary, to give an example.
    – LaRiFaRi
    Jul 20 '15 at 7:58
  • Yes, filecontents was required from a step between to the mwe, because I load datatool in normal operation and load all values from csv files. All other packages ought to be required. Jul 20 '15 at 8:02
2

The \psLorenz macro uses \listplot, and the points of both plots are in the same order (x-values from left to right). In order to fill the area between both curves, you must reverse one of the curves using the ChangeOrder parameter provided explicitely for this case of filling between two \listplot:

\documentclass[pstricks,border=0pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pst-func}

\begin{document}
\psset{lly=-13mm,llx=-9mm,urx=25mm,ury=15mm}%
\psgraph[xAxisLabel={\ },yAxisLabel={\ },Ox=0,Dx=20,Dy=0.2,dx=0.2](-0.0,-0.0)(1,1){6cm}{6cm}%
\pscustom[linestyle=none,fillstyle=solid,fillcolor=red]{%
  \psLorenz[plotstyle=bezier]{0.025 0.2 0.21 0.27 0.295}
  \psLorenz[plotstyle=bezier, ChangeOrder]{ 0.00135847 0.00411338 0.00163124 0.00079123 0.99210568 1}%
}%
\endpsgraph% 
\end{document}

enter image description here

I generated this png with pdftocairo -r 100 -png. When looking at the resulting pdf file with e.g. okular I see an artifact line, which I couldn't remove. The following screenshot shows this:

enter image description here

Alternatively you can use pst-intersect to save the first \psLorenz curve, and then reverse this path when tracing it with \pstracecurve:

\documentclass[pstricks,border=0pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pst-func}
\usepackage{pst-intersect}

\begin{document}
\psset{lly=-13mm,llx=-9mm,urx=25mm,ury=15mm}%
\psgraph[xAxisLabel={\ },yAxisLabel={\ },Ox=0,Dx=20,Dy=0.2,dx=0.2](-0.0,-0.0)(1,1){6cm}{6cm}%
  \pssavepath{Lorenz}{\psLorenz[plotstyle=bezier]{0.025 0.2 0.21 0.27 0.295}}
  \pscustom[fillstyle=solid,fillcolor=red]{%
    \pstracecurve[reversepath]{Lorenz}
    \psLorenz[plotstyle=bezier]{ 0.00135847 0.00411338 0.00163124 0.00079123 0.99210568 1}%
  }%
\endpsgraph% 
\end{document}

Note, that for this latter solution you need the development version of pst-intersect from https://github.com/cbersch/pst-intersect.

enter image description here

3
  • Can you tell my, why you are going to create a png? Because if I use pdf only, I dont see this line of example 1. Jul 23 '15 at 11:49
  • I only created the png to show the result here. As I wrote, I do see the additional line with some viewer, with other not: Line appears with okular, Acrobat Reader, gsview. Line does not appear with mupdf, foxit, firefox (pdf.js), chrome (pdfium), pdftocairo.
    – Christoph
    Jul 23 '15 at 12:08
  • ok, thank you. I will once more try the second solution and download the new version of your package. I will wait one or two more days, maybe someone knows the reason for the line... Jul 23 '15 at 12:29
1

use two single fills and, of course, do not use the curve style bezier for a Lorenz curve:

\documentclass[pstricks,border=10pt]{standalone}
\usepackage{pst-func}

\begin{document}
    \psset{lly=-13mm,llx=-9mm,urx=5mm,ury=5mm}%
    \psgraph[xAxisLabel={},yAxisLabel={},Dx=20,Dy=0.2,
      dx=0.2](0,0)(1,1){6cm}{6cm}%
        \psLorenz*[linecolor=blue!40]{0.025 0.2 0.21 0.27 0.295}
        \kern0.5pt% to get rid of a small vertical rule
        \psLorenz*[linecolor=white,dimen=inner]{ 0.00135847 0.00411338 0.00163124 0.00079123 0.99210568 1}
    \endpsgraph 

\end{document}

enter image description here

2
  • But the goal is to fill between the to curves, see answer below... Jul 24 '15 at 12:17
  • see my edited answer
    – user2478
    Jul 24 '15 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.