TeX - LaTeX Asked by Julio Michael Stern on January 11, 2021
How can I set-up in tikz a grid using the (r,g,b) — or (c,b,a) in the figure — “redundant” coordinate system, and then draw a single triangle specified by 2 coordinates in a given color?
For example, how to set up the grid in the figure, and then draw the triangle [r= +2, b= -1] in orange, or the triangle [r= +2, g= -2] in violet ?
You could use sth. like this:
€dit: Triangles.
%documentclass[]{article}
documentclass[margin=5pt, tikz]{standalone}
usepackage{tikz}
usetikzlibrary{shapes.geometric}
begin{document}
pgfmathsetmacroxMax{8}
pgfmathsetmacroyMax{7}
pgfmathsetmacros{2*sqrt(3)/3}
begin{tikzpicture}[font=footnotesize,
x={(1,0)}, y={(60:1)},
>=latex,
Point/.style={draw=red, fill=white},
shape triangle/.style = {draw, thick, regular polygon, regular polygon sides=3, minimum height=s cm, % anchor=center,
inner sep=0pt,
},
triangle/.style={shape triangle, shift={(0.5,0.25*s cm)}},
triangle*/.style={shape triangle, shape border rotate=180, , shift={(0.5,-0.25*s cm)}},
]
% Contents
fill[purple] (0,3) -- (0,4) -- (4,0) -- (3,0) --cycle;
node[triangle*, fill=green] at (4,4) {$downarrow$};
node[triangle, fill=green!77!red] at (4,4) {$uparrow$};
node[triangle, fill=red] at (2,5) {a};
node[triangle, fill=cyan] at (2,3) {};
node[triangle*, fill=yellow] at (0,7) {};
% CoSy
begin{scope}[very thin]
clip[] (0,0) -- (xMax,0) -- (xMax cm+pgflinewidth, yMax) -- (pgflinewidth,yMax) --cycle;
% Contents - cliped
fill[blue!33, opacity=0.7] (0,1) rectangle (xMax,2);
fill[purple!33, opacity=0.7] (6,0) -- (7,0)--(7,8)--(6,8)--cycle;
foreach y in {0,...,yMax}{
tikzset{ temp/.style={fill=pink, draw=none,opacity=0.1} }
node[triangle*, temp] at (6,y) {};
node[triangle, temp] at (6,y) {};
}
% CoSy 1/2 - "grid"
foreach x in {0,...,xMax}{
draw[] (x,0) -- (x,yMax);
}
%
pgfmathsetmacroyMAX{2*yMax}
foreach y in {0,...,yMAX}{
draw[] (0,y) -- (xMax,y);
draw[] (0,y) -- (y,0);
}
end{scope}
% CoSy 2/2 - "axes"
draw[thick,->] (0,0) -- (xMax+0.5,0) node[below]{$x$};
draw[thick,->] (0,0) -- (0,yMax+0.5) node[left]{$y$};
foreach x in {0,...,xMax}{
draw[] (x,2pt) -- (x,-2pt) node[below] {x};
}
foreach y in {0,...,yMax}{
draw[] (2pt,y) -- (-2pt,y) node[left] {ify 0 else yfi};
}
% Contents - Points
draw[Point, draw=green] (4,4) circle(2pt);
draw[Point] (0,1) circle(2pt);
draw[Point] (3,3.5) circle(2pt);
draw[Point] (4,6) circle(2pt);
end{tikzpicture}
end{document}
Correct answer by cis on January 11, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP