Graphics, Figures & Tables ⇒ A question about filling a region with colour and pattern
A question about filling a region with colour and pattern
I would like to fill this region using a shape/pattern construct (see Latex file), but I have problem with defining my region's boundary to achieve this.
Any help is highly appreciated!
Best regards,
Kent Holing
NORWAY
- Attachments
-
- latexforum2.pdf
- (3.55 KiB) Downloaded 292 times
-
- latexforum2.tex
- (1.63 KiB) Downloaded 498 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10326
- Joined: Mon Mar 10, 2008 9:44 pm
A question about filling a region with colour and pattern
A classic way is using
\clip
in a scope
for defining the boundary and then \filldraw
. Not so easy this time, when I quickly tested it, but I may find a way later today.Stefan
A question about filling a region with colour and pattern
The region to be shaded is between the two parabola segments in red and the red line.
- Attachments
-
- latexforum2.pdf
- (3.55 KiB) Downloaded 372 times
A question about filling a region with colour and pattern
Kent
- Stefan Kottwitz
- Site Admin
- Posts: 10326
- Joined: Mon Mar 10, 2008 9:44 pm
A question about filling a region with colour and pattern
This is quickly made

Code: Select all
\begin{scope}
\clip (O) parabola (P) -- (P2) -- (P1) -- ++(0,-2);
\clip (P1) parabola (P2) -- (P) -- (0,-4) -- (O) -- ++(-3,-4);
\clip (O) parabola (P1) -- (P2) -- (P) -- (-4,-4) ;
\clip (P2) parabola (P) -- (0,-5) -- (O) -- ++(0,-4) -- (P1);
\filldraw [red] (O) circle (20);
\end{scope}
Code: Select all
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[rotate=-90]
\coordinate (O) at (0,0);
\coordinate (S) at (-2,2);
\coordinate (P) at (-4,4);
\coordinate (P1) at (2,1);
\coordinate (P2) at (-1,5/2);
\draw[black,thick] (0,0) parabola (5,25/4);
\draw[black,thick] (0,0) parabola (-5,25/4);
\draw[black,thick] (-2,2) parabola (-5,6.5);
\draw[black,thick] (-2,2) parabola (1,6.5);
\draw[red,ultra thick] (O) parabola (P);
\draw[red,ultra thick] (O) parabola (P1);
\draw[red,ultra thick] (S) parabola (P);
\draw[red,ultra thick] (S) parabola (P2);
\draw[red,ultra thick] (P1) parabola (P2);
\begin{scope}
\clip (O) parabola (P) -- (P2) -- (P1) -- ++(0,-2);
\clip (P1) parabola (P2) -- (P) -- (0,-4) -- (O) -- ++(-3,-4);
\clip (O) parabola (P1) -- (P2) -- (P) -- (-4,-4) ;
\clip (P2) parabola (P) -- (0,-5) -- (O) -- ++(0,-4) -- (P1);
\filldraw [red] (O) circle (20);
\end{scope}
\end{tikzpicture}
\end{document}
A question about filling a region with colour and pattern
I finally succeeded in getting what my figure should really like, see the attached file.

Kent
- Attachments
-
- figure.pdf
- (7.76 KiB) Downloaded 402 times
- Stefan Kottwitz
- Site Admin
- Posts: 10326
- Joined: Mon Mar 10, 2008 9:44 pm
A question about filling a region with colour and pattern
Would you like to add this as example to the TikZ gallery on TeXample.net? If yes, you could post the full code here.
What I see as a good point for learners, is filling an area made by several different curves by intersecting clipping areas.
Stefan
A question about filling a region with colour and pattern
However, looking at some examples I see that people document their examples excellently.
My source code, I am afraid, is a little too obscure for others to read without extensive editing. It was intended only for me to read. (Among other things, I am using several private written macros not directly related to the issue of region shading we want to highlight.)
I am soon finally getting access to upgrade my PGF version to PGF 3.0. After that I will update the code and come back to you on this issue.
Best regards,
Kent