TransWikia.com

filling areas in tikzpicture

TeX - LaTeX Asked by Noob_Latex on December 1, 2020

I did this with geogebra, then copied the code and generate the drawing.
I am missing how too fill some areas too make it look like in the pic I added.
enter image description here

documentclass[10pt]{article}
usepackage{pgfplots}

pgfplotsset{compat=1.15}
usepackage{mathrsfs}
usetikzlibrary{arrows}
pagestyle{empty}
begin{document}

begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.35cm,y=0.35cm]
clip(-2.6084198246281884,-1.775158614705993) rectangle (39.01911524098169,25.132373556978752);
draw [line width=1pt,color=black] (0,0)-- (0,6);
draw [line width=1pt,color=black] (0,6)-- (1,6);
draw [line width=1pt,color=black] (2,6)-- (3,6);
draw [line width=1pt,color=black] (3,6)-- (3,9);
draw [line width=1pt,color=black] (4,6)-- (5,6);
draw [line width=1pt,color=black] (5,0)-- (5,6);
draw [line width=1pt,color=black] (4,6)-- (4,8);
draw [line width=1pt,color=black] (7,0)-- (7,6);
draw [line width=1pt,color=black] (8,6)-- (7,6);
draw [line width=1pt,color=black] (8,6)-- (8,10);
draw [line width=1pt,color=black] (9,6)-- (10,6);
draw [line width=1pt,color=black] (10,6)-- (10,8);
draw [line width=1pt,color=black] (11,6)-- (11,8);
draw [line width=1pt,color=black] (11,6)-- (12,6);
draw [line width=1pt,color=black] (12,6)-- (12,0);
draw [line width=1pt,color=black] (9,6)-- (9,10);
draw [line width=1pt,color=black] (1,6)-- (1,11);
draw [line width=1pt,color=black] (2,6)-- (2,10);
draw [line width=1pt,color=black] (2,10)-- (8,10);
draw [line width=1pt,color=black] (1,11)-- (28,11);
draw [line width=1pt,color=black] (9,10)-- (15,10);
draw [line width=1pt,color=black] (14,0)-- (14,6);
draw [line width=1pt,color=black] (15,6)-- (14,6);
draw [line width=1pt,color=black] (15,6)-- (15,10);
draw [line width=1pt,color=black] (16,10)-- (16,6);
draw [line width=1pt,color=black] (16,6)-- (17,6);
draw [line width=1pt,color=black] (18,6)-- (19,6);
draw [line width=1pt,color=black] (19,6)-- (19,0);
draw [line width=1pt,color=black] (21,0)-- (21,6);
draw [line width=1pt,color=black] (21,6)-- (22,6);
draw [line width=1pt,color=black] (22,6)-- (22,10);
draw [line width=1pt,color=black] (23,10)-- (23,6);
draw [line width=1pt,color=black] (23,6)-- (24,6);
draw [line width=1pt,color=black] (25,6)-- (26,6);
draw [line width=1pt,color=black] (26,6)-- (26,0);
draw [line width=1pt,color=black] (16,10)-- (22,10);
draw [line width=1pt,color=black] (23,10)-- (29,10);
draw [line width=1pt,color=black] (3,9)-- (8,9);
draw [line width=1pt,color=black] (4,8)-- (8,8);
draw [line width=1pt,color=black] (9,9)-- (15,9);
draw [line width=1pt,color=black] (16,9)-- (22,9);
draw [line width=1pt,color=black] (28,11)-- (28,15);
draw [line width=1pt,color=black] (29,10)-- (29,15);
draw [line width=1pt,color=black] (23,9)-- (34,9);
draw [line width=1pt,color=black] (28,15)-- (26,17);
draw [line width=1pt,color=black] (26,17)-- (26,20);
draw [line width=1pt,color=black] (26,20)-- (29,23);
draw [line width=1pt,color=black] (29,23)-- (29,22);
draw [line width=1pt,color=black] (29,15)-- (29,22);
draw [line width=1pt,color=black] (29,19)-- (34,19);
draw [line width=1pt,color=black] (29,18)-- (34,18);
draw [line width=1pt,color=black] (34,23)-- (34,19);
draw [line width=1pt,color=black] (34,18)-- (34,15);
draw [line width=1pt,color=black] (34,23)-- (37,20);
draw [line width=1pt,color=black] (37,20)-- (37,17);
draw [line width=1pt,color=black] (37,17)-- (35,15);
draw [line width=1pt,color=black] (34,15)-- (34,9);
draw [line width=1pt,color=black] (35,15)-- (35,8);
draw [line width=1pt,color=black] (0,4)-- (1.6,4);
draw [line width=1pt,color=black] (1.6,4)-- (1.6,0);
draw [line width=1pt,color=black] (3.4,0)-- (3.4,4);
draw [line width=1pt,color=black] (3.4,4)-- (5,4);
draw [line width=1pt,color=black] (7,2)-- (8.6,2);
draw [line width=1pt,color=black] (8.6,2)-- (8.597289004768815,-0.00494417061539465);
draw [line width=1pt,color=black] (12,2)-- (10.4,2);
draw [line width=1pt,color=black] (10.4,2)-- (10.4,0);
draw [line width=1pt,color=black] (7,4)-- (12,4);
draw [line width=1pt,color=black] (14,4)-- (19,4);
draw [line width=1pt,color=black] (14,2)-- (15.6,2);
draw [line width=1pt,color=black] (15.6,2)-- (15.6,0);
draw [line width=1pt,color=black] (19,2)-- (17.4,2);
draw [line width=1pt,color=black] (17.4,2)-- (17.4,0);
draw [line width=1pt,color=black] (21,4)-- (22.6,4);
draw [line width=1pt,color=black] (26,4)-- (24.4,4);
draw [line width=1pt,color=black] (24.4,4)-- (24.4,0);
draw [line width=1pt,color=black] (22.6,4)-- (22.6,0);
draw (27,19) node[anchor=north west] {T};
draw (35,19) node[anchor=north west] {C};
draw [line width=1pt,color=black] (9,8.006521194140134)-- (10,8);
draw [line width=1pt,color=black] (11,8)-- (15,8.006521194140134);
draw [line width=1pt,color=black] (17,6)-- (17,8);
draw [line width=1pt,color=black] (16,8)-- (17,8);
draw [line width=1pt,color=black] (18,6)-- (18,8);
draw [line width=1pt,color=black] (22,8)-- (18,8);
draw [line width=1pt,color=black] (24,6)-- (24,8);
draw [line width=1pt,color=black] (23,8.023862255462648)-- (24,8);
draw [line width=1pt,color=black] (25,6)-- (25,8);
draw [line width=1pt,color=black] (25,8)-- (35,8);
draw [line width=1pt,color=black] (34,18)-- (34,19);
draw [line width=1pt,color=black] (1,6)-- (2,6);
draw [line width=1pt,color=black] (3,6)-- (4,6);
draw [line width=1pt,color=black] (22,6)-- (23,6);
draw [line width=1pt,color=black] (24,6)-- (25,6);

end{tikzpicture}
end{document}

One Answer

If geogebra doesn't have the option to fill colors, then you have to draw continuous closed paths to fill with the required color/pattern. You can draw grid lines to find the exact coordinates and draw these paths. Here is an example:

enter image description here

I used two sets of grid lines - one with spacing 1 (black) and other with spacing 5 (red). Using the following commands.

draw[step=1.0,thin,gray] (-2,-1) grid (40,26);
draw[step=5.0,red] (-2,-1) grid (40,26);

Using these grids, I have found the coordinates and filled a small portion. I hope you do the remaining with the help of this code. You can remove the grid lines in the final version. The complete code is given below.

documentclass[10pt]{article}
usepackage{pgfplots}

pgfplotsset{compat=1.15}
usepackage{mathrsfs}
usetikzlibrary{arrows}
pagestyle{empty}
begin{document}

begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.35cm,y=0.35cm]
draw[step=1.0,thin,gray] (-2,-1) grid (40,26);
draw[step=5.0,red] (-2,-1) grid (40,26);
clip(-2.6084198246281884,-1.775158614705993) rectangle (39.01911524098169,25.132373556978752);
draw [line width=1pt,color=black] (0,0)-- (0,6);
draw [line width=1pt,color=black] (0,6)-- (1,6);
draw [line width=1pt,color=black] (2,6)-- (3,6);
draw [line width=1pt,color=black] (3,6)-- (3,9);
draw [line width=1pt,color=black] (4,6)-- (5,6);
draw [line width=1pt,color=black] (5,0)-- (5,6);
draw [line width=1pt,color=black] (4,6)-- (4,8);
draw [line width=1pt,color=black] (7,0)-- (7,6);
draw [line width=1pt,color=black] (8,6)-- (7,6);
draw [line width=1pt,color=black] (8,6)-- (8,10);
draw [line width=1pt,color=black] (9,6)-- (10,6);
draw [line width=1pt,color=black] (10,6)-- (10,8);
draw [line width=1pt,color=black] (11,6)-- (11,8);
draw [line width=1pt,color=black] (11,6)-- (12,6);
draw [line width=1pt,color=black] (12,6)-- (12,0);
draw [line width=1pt,color=black] (9,6)-- (9,10);
draw [line width=1pt,color=black] (1,6)-- (1,11);
draw [line width=1pt,color=black] (2,6)-- (2,10);
draw [line width=1pt,color=black] (2,10)-- (8,10);
draw [line width=1pt,color=black] (1,11)-- (28,11);
draw [line width=1pt,color=black] (9,10)-- (15,10);
draw [line width=1pt,color=black] (14,0)-- (14,6);
draw [line width=1pt,color=black] (15,6)-- (14,6);
draw [line width=1pt,color=black] (15,6)-- (15,10);
draw [line width=1pt,color=black] (16,10)-- (16,6);
draw [line width=1pt,color=black] (16,6)-- (17,6);
draw [line width=1pt,color=black] (18,6)-- (19,6);
draw [line width=1pt,color=black] (19,6)-- (19,0);
draw [line width=1pt,color=black] (21,0)-- (21,6);
draw [line width=1pt,color=black] (21,6)-- (22,6);
draw [line width=1pt,color=black] (22,6)-- (22,10);
draw [line width=1pt,color=black] (23,10)-- (23,6);
draw [line width=1pt,color=black] (23,6)-- (24,6);
draw [line width=1pt,color=black] (25,6)-- (26,6);
draw [line width=1pt,color=black] (26,6)-- (26,0);
draw [line width=1pt,color=black] (16,10)-- (22,10);
draw [line width=1pt,color=black] (23,10)-- (29,10);
draw [line width=1pt,color=black] (3,9)-- (8,9);
draw [line width=1pt,color=black] (4,8)-- (8,8);
draw [line width=1pt,color=black] (9,9)-- (15,9);
draw [line width=1pt,color=black] (16,9)-- (22,9);
draw [line width=1pt,color=black] (28,11)-- (28,15);
draw [line width=1pt,color=black] (29,10)-- (29,15);
draw [line width=1pt,color=black] (23,9)-- (34,9);
draw [line width=1pt,color=black] (28,15)-- (26,17);
draw [line width=1pt,color=black] (26,17)-- (26,20);
draw [line width=1pt,color=black] (26,20)-- (29,23);
draw [line width=1pt,color=black] (29,23)-- (29,22);
draw [line width=1pt,color=black] (29,15)-- (29,22);
draw [line width=1pt,color=black] (29,19)-- (34,19);
draw [line width=1pt,color=black] (29,18)-- (34,18);
draw [line width=1pt,color=black] (34,23)-- (34,19);
draw [line width=1pt,color=black] (34,18)-- (34,15);
draw [line width=1pt,color=black] (34,23)-- (37,20);
draw [line width=1pt,color=black] (37,20)-- (37,17);
draw [line width=1pt,color=black] (37,17)-- (35,15);
draw [line width=1pt,color=black] (34,15)-- (34,9);
draw [line width=1pt,color=black] (35,15)-- (35,8);
draw [line width=1pt,color=black] (0,4)-- (1.6,4);
draw [line width=1pt,color=black] (1.6,4)-- (1.6,0);
draw [line width=1pt,color=black] (3.4,0)-- (3.4,4);
draw [line width=1pt,color=black] (3.4,4)-- (5,4);
draw [line width=1pt,color=black] (7,2)-- (8.6,2);
draw [line width=1pt,color=black] (8.6,2)-- (8.597289004768815,-0.00494417061539465);
draw [line width=1pt,color=black] (12,2)-- (10.4,2);
draw [line width=1pt,color=black] (10.4,2)-- (10.4,0);
draw [line width=1pt,color=black] (7,4)-- (12,4);
draw [line width=1pt,color=black] (14,4)-- (19,4);
draw [line width=1pt,color=black] (14,2)-- (15.6,2);
draw [line width=1pt,color=black] (15.6,2)-- (15.6,0);
draw [line width=1pt,color=black] (19,2)-- (17.4,2);
draw [line width=1pt,color=black] (17.4,2)-- (17.4,0);
draw [line width=1pt,color=black] (21,4)-- (22.6,4);
draw [line width=1pt,color=black] (26,4)-- (24.4,4);
draw [line width=1pt,color=black] (24.4,4)-- (24.4,0);
draw [line width=1pt,color=black] (22.6,4)-- (22.6,0);
draw (27,19) node[anchor=north west] {T};
draw (35,19) node[anchor=north west] {C};
draw [line width=1pt,color=black] (9,8.006521194140134)-- (10,8);
draw [line width=1pt,color=black] (11,8)-- (15,8.006521194140134);
draw [line width=1pt,color=black] (17,6)-- (17,8);
draw [line width=1pt,color=black] (16,8)-- (17,8);
draw [line width=1pt,color=black] (18,6)-- (18,8);
draw [line width=1pt,color=black] (22,8)-- (18,8);
draw [line width=1pt,color=black] (24,6)-- (24,8);
draw [line width=1pt,color=black] (23,8.023862255462648)-- (24,8);
draw [line width=1pt,color=black] (25,6)-- (25,8);
draw [line width=1pt,color=black] (25,8)-- (35,8);
draw [line width=1pt,color=black] (34,18)-- (34,19);
draw [line width=1pt,color=black] (1,6)-- (2,6);
draw [line width=1pt,color=black] (3,6)-- (4,6);
draw [line width=1pt,color=black] (22,6)-- (23,6);
draw [line width=1pt,color=black] (24,6)-- (25,6);

fill[red,opacity=0.5] (29,23) -- (26,20) -- (26,17) -- (28,15) --(28,11) -| (1,6) -- (2,6) -- (2,10) -| (29,23) ;
end{tikzpicture}
end{document}

Answered by nidhin on December 1, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP