How could we add the cross-and-dash pattern as the following figure?

Enter image description here

Part of my code so far is:

    \usepackage{tkz-fct} \usetkzobj{all}


\draw[thick] (1.7, 1.5) to[out=90,in=180] (5.8, 5.2);
\draw (.7, 1.5) to[out=90,in=180] (5.8, 3.5) ;
    \draw[->, very thick] (0,0) -- (6,0);
    \draw[->, very thick] (0,0) -- (0,6);
\fill (2.17,3.215) circle (1.5pt);
\draw[dashed] (2.17,3.215)--(2.17,0);


4 Answers 4


This approach uses the pgfplots fillbetween library without requiring you to switch to using pgfplots' axis environment.

I also used the intersections library to avoid the need to manually specify the intersection point.

Suitable pattern definitions are left as an exercise for the reader. :-)


  \draw[thick,name path=thick] 
    (1.7, 1.5) to[out=90,in=180] (5.8, 5.2);
  \draw[name path=thin] 
    (.7, 1.5) to[out=90,in=180] (5.8, 3.5) ;
  \draw[->, very thick] (0,0) -- (6,0);
  \draw[->, very thick] (0,0) -- (0,6);
  \fill[name intersections={of=thick and thin, by={intersect}}] 
    (intersect) circle (1.5pt);
  \draw[dashed] (intersect) -- (intersect |- 0,0);
    of=thick and thin,split,
    every even segment/.style={pattern=crosshatch}
  ] {pattern=grid};

enter image description here

  • Could something like \draw[pattern=horizontal lines] (intersect) --..; this work? I'd like to avoid compiling my tex with XeLaTeX and remain with pdfLaTeX.
    – Y_gr
    Commented Feb 18, 2015 at 11:42
  • 2
    What about this requires XeLaTeX? I produced the output above using pdfLaTeX. Commented Feb 18, 2015 at 12:00
  • You're right. There was a clash with xcolor package and I couldn't do it with pdfLaTeX.
    – Y_gr
    Commented Feb 19, 2015 at 16:12

Like this? (using pgfplots and its fillbetween library)



axis lines=left,
\addplot+[name path=A,no marks,samples=100,domain=1.2:3,black] {4*ln(x)};
\addplot+[name path=B,no marks,samples=100,domain=1.2:3,black] {x^2*ln(x)};
\addplot fill between[of=A and B,soft clip={domain=1:3},
        every segment no 0/.style={pattern=north east lines,pattern color=gray},
        every segment no 1/.style={pattern=fivepointed stars,pattern color=gray},];


enter image description here

  • 2
    Argh, you're too fast! :-) I wasted time figuring how to use fillbetween outside axis. Commented Feb 17, 2015 at 15:41
  • 1
    @PaulGessler, I guess that Gonzalo is one of the PGF developers. lol
    – Sigur
    Commented Feb 17, 2015 at 18:21

Here's a slightly more random attempt with Metapost using a very rudimentary implementation of a Poisson disc sampling algorithm which I hope captures the spirit of the OP request.

enter image description here

This is a much longer routine than I'd normally attempt in MP - I would welcome suggestions for improvements or bug fixes.

prologues := 3;
outputtemplate := "%j%c.eps";

% Fill "shape" with "mark" using Poisson Disc 
% Sampling with radius "r" and trial placements "k".
% Smaller "r" and larger "k" are slower.
vardef pds_fill(expr shape, mark, r, k) =
    save w, h, diagonal, cellsize, imax, jmax, m, n, far_enough_away, 
         a, p, g, random, temp, trial, xx, yy, ii, jj, output;
    numeric w, h, cellsize, imax, jmax, g[], m, n; 
    pair diagonal;
    diagonal = urcorner shape - llcorner shape;
    w = xpart diagonal;
    h = ypart diagonal;
    cell_size := r/sqrt(2);

    imax := floor(w/cell_size);
    jmax := floor(h/cell_size);
    for i = -1 upto 1+imax:
      for j = -1 upto 1+jmax:
        g[i][j] := -1;

    z0 = center shape;
    g[floor(x0/cell_size)][floor(y0/cell_size)] := 0; 
    m := 0; % index of marks made
    n := 0; % index of active points
    a[n] = m;
    boolean far_enough_away;
    pair p[];
      exitif n<0;
      % shuffle a[0..n]
      for i=n step -1 until 0:
        random := floor uniformdeviate i;
        temp := a[i]; a[i] := a[random]; a[random] := temp;
      % now a[n] is our random point
      trial := 0;
         % find a trial point
         trial := trial+1;
         exitif trial>k;
         p0 := z[a[n]];
         p[trial] := p0 shifted (r+uniformdeviate r,0) rotatedabout(p0,uniformdeviate 360);
         xx := xpart p[trial];
         yy := ypart p[trial];
         % test it if it is inside the shape's bbox
         if  (xpart llcorner shape < xx) and (xx < xpart urcorner shape)
         and (ypart llcorner shape < yy) and (yy < ypart urcorner shape):
             ii := floor(xx/cell_size);
             jj := floor(yy/cell_size);
             far_enough_away := true;
             for i=ii-1 upto ii+1:
               for j=jj-1 upto jj+1:
                 if known g[i][j]:
                    if (g[i][j] > -1):
                       if (x[g[i][j]] - xx) ++ (y[g[i][j]] - yy) < r:
                          far_enough_away := false;
           far_enough_away := false;
         exitif far_enough_away;

      if far_enough_away:
        m := m+1;
        n := n+1;
        z[m] = p[trial];
        a[n] := m;
        g[ii][jj] := m;
        n := n-1; % ie remove a[n] from next shuffle
    % now we have the "m" points we need
    picture output; output = image(for i=0 upto m: draw mark shifted z[i]; endfor);
    clip output to shape;
    draw output;

u = 1cm;
path p[]; 
p1 = ((1,1) {up} .. {right} (10,6)) scaled u;
p2 = ((3,1) {up} .. {right} (10,10)) scaled u;

path xx, yy;
xx = origin -- right scaled 11u;
yy = origin -- up    scaled 11u;
drawarrow xx withcolor .5 white;
drawarrow yy withcolor .5 white;

path A, B;
A = buildcycle(p1,p2,xx shifted (0,u)); 
B = buildcycle(p1,p2,yy shifted (10u,0)); 
fill A withcolor .8[red,white];
fill B withcolor .8[blue,white];
pds_fill(A, btex $-$ etex, 10, 10);
pds_fill(B, btex $+$ etex, 10, 10);
draw p1; draw p2;


Done with mfpic.

I used the \tile environment to create the starred tiling pattern and the \tess{} command to fill the second closed region with this pattern. The hatching of the first closed region is done with the \lhatch command (lines going from upper left to lower right). The intersection is automatically found by mfpic, or rather by MetaPost since mfpic is in fact an interface to this program (or to METAFONT).

Edit: I've replaced the starred pattern by one made of crosses, as it seems to be wished by the OP.

    \begin{tile}{crossed, 1bp, 7, 7, false}
    \setmfarray{path}{P}{(0.5, 0.25){up}.. (\xmax, 1.7){right}, 
        (0.15, 0.25){up}..(\xmax, 1){right}}
        \mfobj{P1 cutafter P2}\mfobj{reverse P2 cutbefore P1}
        \mfobj{reverse P1 cutafter P2}\mfobj{P2 cutbefore  P1}

The .tex file is to be typeset with LaTeX (whatever the engine), then the resulting .mp file with MetaPost and then again the .tex file with LaTeX.

enter image description here

You must log in to answer this question.

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