Probably my Title is not so informative. My problem is that I try to "draw" hyperedges on some vertices with the following code:  \usepackage{tikz}  \tikzstyle{vertex} = [fill, shape=circle, opacity=1, node distance=80pt] \tikzstyle{hyperedge} = [fill, opacity=1, cap=round, join=round, line width=60pt] \tikzstyle{elabel} = [fill, shape=circle, node distance=30pt]  \pgfdeclarelayer{background} \pgfsetlayers{background,main}  \begin{document}  \begin{tikzpicture} \node[vertex,label=above left:$v_1$] (v1) {}; \node[vertex,right of=v1,label=above right:$v_2$] (v2) {}; \node[vertex,below of=v1,label=below left:$v_3$] (v3) {}; \node[vertex,right of=v3,label=below right:$v_4$] (v4) {};  \begin{pgfonlayer}{background}  \draw[hyperedge, color=yellow] (v1.center)--(v2.center)--(v3.center)--cycle; \draw[hyperedge, color=pink, line width=45pt] (v2.center)--(v3.center)--(v4.center)--cycle;  \end{pgfonlayer}  \node[elabel,color=yellow,label=right:$C_1$]  (e1) at (-3,0) {}; \node[elabel,below of=e1,color=pink,label=right:$C_2$]  (e2) {}; \end{tikzpicture}  \end{document}   This produces the following:    It is not bad, but the intersection is not so visible. If I set opacity of the hyperedges to 0.5:  \tikzstyle{hyperedge} = [fill, opacity=0.5, cap=round, join=round, line width=60pt]   I get:    The intersection is more visible here, but since the "fill" and the "lines" of the cycles also intersect, the affected  parts become more opaque(?). Is there a workaround for this situation? Maybe to draw the lines only on one side of the cycle avoiding intersection with the fill, but is it possible?
122521
I have a few circles in a drawing, and want to highlight some of them.  \begin{tikzpicture}  \coordinate (A1) at (0,0); \coordinate (A2) at (1,0); \coordinate (A3) at (1,1); \coordinate (B)  at (1,0);  \draw (A1) -- (A2); \draw (A1) -- (A3); \draw (B)  -- (A3);  \foreach \point in {A1,A2,A3,B} {    \fill [black,draw=white](\point) circle (3pt); }  \pgfsetstrokeopacity{.3} \pgfsetfillopacity{.3} \fill [red,draw,rounded corners,line width=9pt] (A1) -- (A2) -- (A3) -- cycle; \pgfsetstrokeopacity{1} \pgfsetfillopacity{1} \end{tikzpicture}   I would like the whole area surrounding the A points to be of the same color, but the strokeopaticy and the fillopacity interfere.  Is there some ay I can prevent this?  Note: in my actuall use scenario, there are too many coordinates for manual adjusting to be an option (otherwise I would just do with a fill with rounded corners, with points calculated manually).
17033
How do I color intersection of two ellipses in different color. For instances, the ellipses should themselves be colored as yellow and their intersection as red. My code for drawing ellipses is given below  \draw (-4,0) ellipse (8 and 3); \draw (8,0) ellipse (8 and 3);   UPDATE: In the comments to individual answers, I have requested to show it for three ellipses.
113575
I got a problem when I want to color the region bounded by curves \sigma^{(0)}, \sigma^{(1)}, \sigma^{(0)}. I use the command  \draw[fill=red!30, opacity=.5] (h2)--(h3)--(h4)--cycle;   but it is colored only the triangle formed by 3 vertices v_0, v_1, v_2. Like in the image below:    This is my code  \documentclass[12pt]{article}  \usepackage{epsfig,psfrag}  \usepackage{amsmath,amsxtra,amssymb,latexsym,amscd,amsthm} \usepackage[linesnumbered,ruled,vlined]{algorithm2e} \usepackage{graphicx} \setlength{\textwidth}{6.2in} \setlength{\oddsidemargin}{0.3in} \setlength{\evensidemargin}{0in} \setlength{\textheight}{8.7in} \setlength{\voffset}{-.7in} \setlength{\headsep}{26pt} \setlength{\parindent}{10pt}  \usepackage{epic} \usepackage{curves}  \usepackage{tikz, tikz-3dplot, pgfplots} \usepackage{tkz-graph} \usetikzlibrary{calc,arrows.meta} \usetikzlibrary{shapes.geometric,calc} \usetikzlibrary[positioning,patterns] \usetikzlibrary{decorations.markings} \usetikzlibrary{arrows}   \usetikzlibrary{arrows,calc,shapes,decorations.pathreplacing} \usepackage{tikz-cd}   \usepackage{young} \usepackage[vcentermath]{youngtab}  \begin{document} \begin{tikzpicture}   [decoration={markings,mark=at position 0.5 with {\arrow{&gt;}}},    witharrow/.style={postaction={decorate}},    shorten &lt;&gt;/.style={shorten &lt;=#1,shorten &gt;=#1},    dot/.style={radius=2pt}   ]     % ellipse   \begin{scope}     \fill            (-2,0) coordinate (h1) circle[dot] node[left](k1){$q$}           (2,0) coordinate (h2) circle[dot] node[below](k2){$v_0$}           (4,2) coordinate (h3) circle[dot] node[above](k3){$v_2$}           (5,-2) coordinate (h4) circle[dot] node[below](p3){$v_1$}           (0,0) coordinate (a3)  node[left](p3){}            (5,0.5) coordinate (b3)  node[right]{}           (1,-0.5) coordinate (c3) node[right]{};        \draw[bend right=20,witharrow]  (h1) to node [anchor=south]{$\alpha(v_0)$} (h2);             \draw[bend left=30,witharrow]  (h1) to node [anchor=south]{$\alpha(v_2)$} (h3);               \draw[bend right=30,witharrow]  (h1) to node [anchor=north]{$\alpha(v_1)$} (h4);               \draw[bend right=30,witharrow]  (h2) to node [anchor=south]{$\sigma^{(1)}$} (h3);             \draw[bend left=20,witharrow]  (h2) to node [anchor=north]{$\sigma^{(2)}$} (h4);            \draw[bend left=25,witharrow]  (h3) to node [anchor=west]{$\sigma^{(0)}$} (h4);  \draw ($0.5*(a3)+0.5*(b3)$) circle[x radius=6,y radius=4];     \node at ($(a3)+(6,2.5)$) (X3) {$X$};           \draw[fill=red!30, opacity=.5] (h2)--(h3)--(h4)--cycle;     \end{scope}           \end{tikzpicture} \end{document}   How can I fix this problem? Can any one give me some idea?
119692
I want to draw an arbitrary closed surface like following figure. How can i do it?   Here is the MWE:  \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \shade[line width=2pt, color=blue] (0, 0) .. controls(1,2) .. (3, 0) ; \end{tikzpicture} \end{document}   In my code, color option doesn't work and I can't close the \controls.
92367
I have always wondered whether it was possible to define some sort of "relative" transparency in TikZ. What do I mean?  Sometimes, you want a node to be filled in order for its content to be readable among lines and shapes. Now, imagine you have a TikZ picture on some shaded background. It would be great if one could specify that the node should be opaque with respect to the rest of the picture (or the scope), but stay transparent with respect to the background defined outside.  \documentclass{article}  \usepackage{framed,xcolor,tikz} \definecolor{shadecolor}{gray}{.85}  \begin{document}  \begin{shaded}    \begin{tikzpicture}       \draw (0,0) --node[fill=shadecolor] {a} (5,0);    \end{tikzpicture} \end{shaded}  \end{document}   In the above situation, it is possible to use shadecolor, because this is how the shaded environment works. I would like to know whether a more general solution exists, e.g. one that works in situations where you cannot find out the background color of the surrounding environment.   Updated information  I will try to state things a bit clearer. I often use TikZ for geometric figures and/or plots. Then, sometimes you have lines running through a coordinate label. In most cases, it is enough to slightly change the figure, e.g. by moving the label to a different anchor or even adapt some angle and thus have the line just miss the label.  However, in some cases, there is no other way than to put the label in a filled node with an inner sep of 1 or 2 points, so that it stands out among all other stuff. The main problem is that I have to use the background color to fill my node, normally this is white, but sometimes it might be some gray color.   The example I included is very easy, just to illustrate the problem. In this simple case, I could, of course, just draw the line in two pieces. In a normal use case, this is not possible.  So another way of saying it: I would love to draw the figure just as if there was a white background, using fill=white for such nodes. And then, after all is finished, I could say that all white stuff becomes transparent, so that the gray (or whatever) background shines through.  Using percusse's solution with transparency groups, it is not possible to achieve what I am looking for. The whole scope becomes partially transparent, so the line is not black anymore and the background is still lightened up. I would want the line to stay completely black and the node fill to be completely invisible.
118159
I am trying to plot a graph using tikz, but I can't seem to be able to highlight the areas between the curves. The result should look something like this:    This is the code I have so far:     \begin{center} \begin{tikzpicture}[scale=0.8]  \draw[-&gt;] (0,-0.5) -- (0,4.5) node[anchor=east] {}; \draw[-&gt;] (-0.5,0) -- (9,0) node[anchor=north] {}; \draw   (1,-0.2) node[anchor=north] {$a$}         (8,-0.2) node[anchor=north] {$b$}                ; \filldraw[fill=black!10](1,0)--(1,2)--(8,2)--(8,0); \draw [](1,3) parabola bend (2.5,1.5)(4.2,2.4);  \draw [](4.2,2.4) parabola bend (5.5,3)(8,0);  \draw[] (1,0)--(1,3); \end{tikzpicture} \end{center}   The end result I would like to achieve is to have C and D higlighted in orange, while A and B in a dark grey. Don't worry about the axes labels or else, I mostly need help with the shading.  Thanks in advance!!
115563
Why does this example only partially work?  \documentclass{minimal} \usepackage{etex} \usepackage{tikz} \usetikzlibrary{shapes,calc,arrows,trees,positioning,through,intersections,fadings} \begin{document}     \begin{tikzpicture}[scale=0.5] \coordinate (a) at (0,0); \coordinate (b) at (6,0); \coordinate (c) at (9,6); \node(A)[label=$A$] at (a) {$\bullet$}; \node(B)[label=50:$B$] at (b)  {$\bullet$}; \node(C)[label=$C$] at (c) {$\bullet$}; \draw[thick] (a)--(b)--(c)--cycle; %           \node(c1) at (a)[draw,circle through=(b)] {}; %           \coordinate(ac) at(intersection 1 of c1 and a--c); %            %           \node(c2) at (ac)[draw,circle through=(b)] {}; %           \node(c3) at (b)[draw,circle through=(ac)] {}; %           \coordinate(bta) at(intersection 1 of c2 and c3 ); %           \node(xx)[label=$C$] at (bta) {$\bullet$}; %       \coordinate(bisa) at(intersection 1 of a--bta and b--c); %       \draw (a)--(bisa); %%%%%%%%%%%%%%%%%%%%%%%%%%% work %%%%%%%%%%%%%%%%%%         \node(c4) at (b)[draw,circle through=(a)] {};             \coordinate(bc) at(intersection 1 of c4 and b--c);             \node(xx)[label=$prova$] at (bc) {$\bullet$};             \node(c5) at (bc)[draw,circle through=(a)] {};             \node(c6) at (a)[draw,circle through=(bc)] {};             \coordinate(btb) at(intersection 1 of c5 and c6 );         \node(xx)[label=$prova$] at (btb) {$\bullet$};         \coordinate(bisb) at(intersection 1 of b--btb and a--c);         \draw (b)--(bisb); %%%%%%%%%%%%%%%%%%%%%%%%%%% work %%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%% it doesn't work%%%%%%%%%%%%%%%%%% \node(c7) at (c)[draw,circle through=(b)] {}; \coordinate(ac) at(intersection 2 of c7 and a--c); \node(xx)[label=$prova2$] at (ac) {$\bullet$}; %%%%%%%%%%%%%%%%%%%%%%%%%%% it doesn't work %%%%%%%%%%%%%%%%%%  \end{tikzpicture} \end{document}
90595
I have created some TikZ code to produce the diagram below (slightly simplified). This is my first real shot at TikZ and its taken me about 8 hours now to get this far. But I don't really begrudge the time, time spent learning is time well spent.  It is loosely based on .  I would like to have a different (variable) number of nodes in each layer, and would like to maintain the connection.  My current idea was to have a list of lists like {{1..3},{1..5},{1..7},{1..4},{1..3}} then I guesss i could use a nested for-each off the index. But that has 2 problems: I would lose my layer number, which I could get around by using count. Secondly, more majorly, I don't seen a good way of knowing how big the next layer is (to make the connections).     \documentclass{article} \usepackage{mathptmx} \usepackage{tikz} \usetikzlibrary{arrows} \usetikzlibrary{calc} \begin{document}   \def\layersep{3.5cm} \def\topnum{5} %\font\nullfont=cmr10 \begin{tikzpicture}[shorten &gt;=1pt,-&gt;,draw=black!50, node distance=\layersep]     \tikzstyle{neuron}=[circle,draw,fill=white!25,minimum size=25pt,inner sep=0pt]     \tikzstyle{bias neuron}=[neuron,dashed]       \foreach \y in {2,...,4}                 \foreach \x in {1,...,5}             \path   node[neuron] (L_\y_\x) at (\x cm,\y*\layersep) {$\sigma(\cdot)$};   %      \foreach  \x in {1,...,5}             \path  node[neuron] (L_1_\x) at (\x cm,1*\layersep) {$x_\x$};      \foreach  \x in {1,...,5}             \path  node[neuron] (L_5_\x) at (\x cm,5*\layersep) {$s_{m}(\cdot)$};       %Add Biases     \foreach \y in {1,...,4}     {         \path node[bias neuron] (B_\y) at (6 cm, 0.55*\layersep+\y*\layersep) {1};         \pgfmathtruncatemacro\nextlayer{\y+1}         \foreach \dest in {1,...,5}             \path (B_\y) edge[dashed] (L_\nextlayer_\dest.south);     }       % Connect every node in the input layer with every node in the     % hidden layer.     \foreach \layer in {1,...,4}         \pgfmathtruncatemacro\nextlayer{\layer+1}         \foreach \source in {1,...,5}             \foreach \dest in {1,...,5}                 \path (L_\layer_\source) edge (L_\nextlayer_\dest);   \end{tikzpicture} \end{document}
57366
Trying to convert a coment into a complete answer for  I think that my solution there worked by chance and that MWijnand  found a wrong behavior in to path library when {x|y}scale has negative values.  Take a look at this example:  \documentclass[tikz,border=2mm]{standalone} \usepackage{bondgraph}           \usetikzlibrary[petri]   \begin{document} \begin{tikzpicture}[thin,&gt;=stealth, every place/.style={draw,thick,minimum size=6mm}]     \node[place] (pG) {$p_G$};     \node[place,right=3cm of pG] (pR) {$p_R$};     \draw[-&gt;] (pR) to [out=150, in=30] (pG);     \begin{scope}[yscale=-1]     \draw[-&gt;,blue] (pR) to [out=150, in=30] (pG);     \end{scope}      \begin{scope}[xscale=-1]     \draw[-&gt;,red] (pR) to [out=150, in=30] (pG);     \end{scope}      \begin{scope}[scale=-1]     \draw[-&gt;,green] (pR) to [out=150, in=30] (pG);     \end{scope}  \end{tikzpicture} \end{document}   and its strange result.    What I would expect was that pR.center was the paths origin and pG.center was the path end. The path would have a out angle affected by scale factor and the drawn path would start on corresponding intersection point over pR border. This is what happens with out angle as you can see around pR node.  But this doesn't happen with in angle (pG node). in angle fixes final anchor at  pG.30 and not at pG.center as expected. It also changes incidence angle for which scale factor is applied.   I think this is wrong and I'll fill a . If I'm wrong or you have a better solution, please let us know.
18322
I have the following image    that was created with this code:  \documentclass[varwidth=true, border=2pt]{standalone} \usepackage{tikz} \usepackage{tkz-euclide}  \begin{document} \usetkzobj{all} \begin{tikzpicture}     \tkzSetUpPoint[shape=circle,size=10,color=black,fill=black]     \tkzSetUpLine[line width=1]     \tkzDefPoints{0/0/A, 3/0/B', 2/2/C, 4/4/C'}     \tkzDefLine[parallel=through C](B',C') \tkzGetPoint{Phelper}     \tkzInterLL(A,B')(C,Phelper) \tkzGetPoint{B}     \tkzDrawLine[add=0 and 0.2](A,B')     \tkzDrawLine[add=0 and 0.2](A,C')     \tkzDrawSegment(B',C')      \node at ($(A)+(-0.1,-0.2)$)  {$A$};     \node at ($(B')+(0.2,-0.2)$)  {$B'$};     \node at ($(C')+(0,0.4)$)  {$C'$};     \node at ($(B)+(0.2,-0.2)$)  {$B$};     \node at ($(C)+(0.28,0.5)$)  {$C$};     \tkzDrawPolygon[ultra thick,color=blue,fill=blue!20](A,B',C')      \tkzDrawPolygon[line width=0.3pt,color=red,fill=red!20](A,B,C)      \tkzDrawPoints(A,B',C',B,C)     \tkzLabelSegment[below,red](A,B){$c$}     \tkzLabelSegment[left,red](A,C){$b$}     \tkzLabelSegment[right,red](B,C){$a$}     \tkzLabelSegment[below,blue,pos=0.8](A,B'){$c'$}     \tkzLabelSegment[left,blue,pos=0.8](A,C'){$b'$}     \tkzLabelSegment[right,blue](B',C'){$a'$} \end{tikzpicture} \end{document}   As you might notice, the space above C' is bigger than necessary. This is because of Phelper. I need Phelper for the construction, but it should not influence the image size in any way. I've tried to get Phelper closer to C, but that seems not to be possible.  How can I stop defined (but not visible) points from influencing image size?  Please note: I wrap code like this in a figure. So images like the one above are only a part of the whole document. So working with standalone does not solve my problem.
50259
I need to illustrate a 2D array data structure in my document. This is a picture I found on the internet. I want something similar.    I also want to show the memory layout in the illustration. Something like this:   Can someone help me with drawing them in Tikz? Thanks in advance.  MWE  \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{tikz} \usetikzlibrary{matrix,backgrounds}  \begin{document} \begin{tikzpicture}[font=\ttfamily, array/.style={matrix of nodes,nodes={draw, minimum size=7mm, fill=green!30},column sep=-\pgflinewidth, row sep=0.5mm, nodes in empty cells, row 1/.style={nodes={draw=none, fill=none, minimum size=5mm}}, row 1 column 1/.style={nodes={draw}}}]  \matrix[array] (array) { 0 &amp; 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 &amp; 6 &amp; 7 &amp; 8 &amp; 9\\   &amp;   &amp;   &amp;   &amp;   &amp;   &amp;   &amp;   &amp;   &amp;  \\}; \node[draw, fill=gray, minimum size=4mm] at (array-2-9) (box) {};  \begin{scope}[on background layer] \fill[green!10] (array-1-1.north west) rectangle (array-1-10.south east); \end{scope}  \draw (array-1-1.north)--++(90:3mm) node [above] (first) {First index}; \draw (array-1-10.east)--++(0:3mm) node [right]{Indices}; \node [align=center, anchor=south] at (array-2-9.north west|-first.south) (8) {Element\\ (at index 8)}; \draw (8)--(box); % \end{tikzpicture} \\ \begin{tikzpicture}[font=\ttfamily, array/.style={matrix of nodes,nodes={draw, minimum size=7mm, fill=red!30},column sep=-\pgflinewidth, row sep=0.5mm, nodes in empty cells, row 1/.style={nodes={draw=none, fill=none, minimum size=5mm}}, row 1 column 1/.style={nodes={draw}}}]  \matrix[array] (array) {  &amp;  &amp;  &amp;  &amp;  &amp;  &amp;  &amp;  &amp;  &amp; \\  &amp;   &amp;   &amp;   &amp;   &amp;   &amp;   &amp;   &amp;   &amp;  \\}; % \end{tikzpicture} \\ \begin{tikzpicture}[font=\ttfamily, array/.style={matrix of nodes,nodes={draw, minimum size=7mm, fill=blue!30},column sep=-\pgflinewidth, row sep=0.5mm, nodes in empty cells, row 1/.style={nodes={draw=none, fill=none, minimum size=5mm}}, row 1 column 1/.style={nodes={draw}}}]  \matrix[array] (array) {  &amp;  &amp;  &amp;  &amp;  &amp;  &amp;  &amp;  &amp;  &amp; \\  &amp;   &amp;   &amp;   &amp;   &amp;   &amp;   &amp;   &amp;   &amp;  \\}; % \end{tikzpicture} \end{document}
38679
How do I make partially shaded nodes with tikz without hardcoding coordinates?  A plain MWE is as follows:  \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[mynode/.style={circle,draw=black,minimum size=10mm}]      \filldraw[fill=gray!25] (-3.5mm,-3.5mm) arc [start angle=225, end angle=405, radius=5mm];     \node at (0,0) [mynode] {\Large $x$};  \end{tikzpicture} \end{document} \end{tikzpicture}   This works, but I had to compute the coordinates of the shaded arc, and is very tedious when I have to work with a large number of nodes. Is there a way to do this automatically?  I have other code that uses , so if the solution can build on top of that it would be even better.
64469
I have the following MWE.  I would like to draw a border without including the $y_3$ (or s3 in the .tex file) -- so it would be a rectangle with its left upper corner changed so that it bypasses s3. Is there a way to create such a border, basically, a rectangular polygon, surrounding a set of nodes?  (EDIT: I was trying to do it using the last command in the tikz file.)  \documentclass{article}  \usepackage{tikz}  \usetikzlibrary{fit,chains}  \begin{document}  \begin{tikzpicture}[node distance=2cm]    \node(s1) {$y_1$};   \node(s2) [right of = s1] {$y_2$};   \node(s3) [right of = s2]{$y_{3}$};   \node(s4) [right of = s3]{$y_4$};   \node(s5) [right of = s4]{$y_5$};  \draw [-&gt;] (s1) -- (s2) ; \draw [-&gt;] (s2) -- (s3) ; \draw [-&gt;] (s3) -- (s4) ; \draw [-&gt;] (s4) -- (s5) ;     \node(x1) [below of = s1]{$x_1$};   \node(x2) [right of = x1] {$X_2$};   \node(x3) [right of = x2] {$X_3$};   \node(x4) [right of = x3] {$X_4$};   \node(x5) [right of = x4] {$X_5$};  \draw [-&gt;] (s1) -- (x1) ; \draw [-&gt;] (s2) -- (x2) ; \draw [-&gt;] (s3) -- (x3) ; \draw [-&gt;] (s4) -- (x4) ; \draw [-&gt;] (s5) -- (x5) ;  \node[rectangle,draw=red, fit=(x3) (x4) (x5) (s4) (s5),inner sep=3mm,line width=1mm](rect2) {};  \end{tikzpicture} \end{document}
101003
I used the following code to draw a picture. I want to make the region insde (0,7), (0,11),(3,8),(3,4) to be red, and the region above it to be gray, but I don't know how to do this.   \documentclass{article} \usepackage{tikz} \begin{document} \pagestyle{empty} \begin{tikzpicture}[scale=0.5]  \draw (1.05cm,2pt) node[above];  %  {$\displaystyle\int_0^{3/2} \!\!x^2\mathrm{d}x$};  \draw[style=help lines] (0,0) grid (3.9,11.9);   % [step=0.25cm]      (1,2) grid +(1,1);  \draw[-&gt;] (-1,0) -- (4,0) node[right] {$i$}; \draw[-&gt;] (0,-1) -- (0,12) node[above] {$j$};  \foreach \x/\xtext in {1/1, 2/2, 3/3} \draw[shift={(\x,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\xtext$};  \foreach \y/\ytext in {1/, 2/, 3/,4/,5/,6/,7/7,8/, 9/, 10/, 11/11} \draw[shift={(0,\y)}] (2pt,0pt) -- (-2pt,0pt) node[left] {$\ytext$};  \draw  {(0,11) -- (3,8)} node[below right] ; \draw  {(0,7) -- (3,4)} node[below right] ; \draw  {(3,8) -- (3,4)} node[below right] ; \end{tikzpicture}  \end{document}
97234
I'm trying to draw a relatively simple chart of a number line, and when one of the nodes is too close to the edge of the plot, it gets cut off.  The code:  \documentclass{article}  \usepackage{natbib} \usepackage{graphicx} \usepackage{pgfplots}  \begin{document}  \begin{tikzpicture} \begin{axis}[   width=\columnwidth,   axis y line=none,   axis lines=left,   axis line style={-},   xmin=0,   xmax=1,   ymin=0,   ymax=1,   xlabel=$\mu$,   scatter/classes={o={mark=*}},   restrict y to domain=0:1,   xtick={0,1} ] \draw[ultra thin] (axis cs:0, 0) -- (axis cs:0,.05); \draw[ultra thin] (axis cs:.4, 0) -- (axis cs:.4,.05); \node[coordinate,label=above:{$B$}] at (axis cs:0.0,0.05) {}; \node[coordinate,label=above:{$A$}] at (axis cs:0.4,0.05) {}; \node[coordinate,label=above:{$b$}] at (axis cs:0.2,0.02) {}; \node[coordinate,label=above:{$a$}] at (axis cs:0.7,0.02) {}; \end{axis}; \end{tikzpicture} \end{document}   The Result:    How do I get the B to fully render?
109610
The image below was obtained with \begin{tikzpicture} \draw (0,0) coordinate (a1) -- (4,3) coordinate (b1) ; \draw (1,3) coordinate (a2) -- (6,1) coordinate (b2) ; \coordinate (c) at (intersection of a1--b1 and a2--b2) ; \coordinate (T) at ($ (c)!0.7!20:(a1) $); \coordinate (p1) at ($(a1)!(T)!(b1)$) ; \draw[-&gt;,thick] (p1) -- (T) ; \coordinate (T) at ($(c)!-0.7!20:(a2)$); % problem below: (p2) seems offset with respect to the correct % orthogonal projection on (a2)--(b2) \coordinate (p2) at ($(a2)!(T)!(b2)$) ; \draw[-&gt;,thick] (p2) -- (T) ; \fill (c)  circle (1pt) node[below]{$C$} ; \fill (p1) circle (1pt) node[above]{$P_1$} ; \fill (p2) circle (1pt) node[below]{$P_2$} ; \end{tikzpicture}   What I need are vectors at P orthogonal to PC. While P1 is acceptable, the vector at P2 is disturbingly leaning leftwards. How can I increase the accuracy of this image? Edit Reading the comments I fear that the above picture is like the infamous blue/black or white/gold dress: is vector at P2 orthogonal to its base line? For me definitely not. My question is what should I do to avoid this problem. Should I abandon calc and revert to trusted hand calculations? Edit The problem becomes more clear if we add a &quot;true&quot; perpendicular for comparison (see the red line below): \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc}  \begin{document}  \begin{tikzpicture} \draw (0,0) coordinate (a1) -- (4,3) coordinate (b1) ; \draw (1,3) coordinate (a2) -- (6,1) coordinate (b2) ; \coordinate (c) at (intersection of a1--b1 and a2--b2) ; \coordinate (T) at ($ (c)!0.7!20:(a1) $); \coordinate (p1) at ($(a1)!(T)!(b1)$) ; \draw[-&gt;,thick] (p1) -- (T) ; \coordinate (T) at ($(c)!-0.7!20:(a2)$); % problem below: (p2) seems offset with respect to the correct % orthogonal projection on (a2)--(b2) \coordinate (p2) at ($(a2)!(T)!(b2)$) ; \draw[-&gt;,thick] (p2) -- (T) ; \fill (c)  circle (1pt) node[below]{$C$} ; \fill (p1) circle (1pt) node[above]{$P_1$} ; \fill (p2) circle (1pt) node[below]{$P_2$} ; % Added for comparison \draw[red] (p2) -- ($(p2)!-1cm!90:(c)$); \end{tikzpicture}  \end{document}
63994
I am trying to locate the vertices of a rectangle and to color the rectangular region.  I specify the y-coordinate as a function value, like \sqrt{3}/2 or \sin(60).  I am getting an error.  \documentclass{amsart} \usepackage{tikz} \usetikzlibrary{calc}   \begin{document} \begin{tikzpicture}  \coordinate (A) at (-1,{-\sqrt{3}/2}); \coordinate (B) at (-1,{\sin(60)}); \coordinate (C) at (2,{\sin(60)); \coordinate (D) at (2,{-\sqrt{3}/2});  \path[fill=yellow] (A) -- (B) -- (C) -- (D) -- cycle;  \node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]below left:$A$}] at (A) {}; \node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]above left:$B$}] at (B) {}; \node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]above right:$C$}] at (C) {}; \node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]below right:$D$}] at (D) {}; \end{tikzpicture}