Tag Info

Hot answers tagged

20

This can't be done automatically, unfortunately, since pgfplots can't do z buffering between different \addplot commands. For this concrete application, you could construct the plot "by hand", however: First, you draw the part of the cone below 0, then you draw the plane and the circle, then you draw the part of the cone above 0. I've used a polar ...


17

The reason the code does not work as provided is that there is only one intersection, and so (intersection-2) does not exist. One way to alleviate this kind of issue is to specify total=\t to contain the total number of intersections and the use a foreach to loop through each intersection: \documentclass{article} \usepackage{tikz} ...


15

Reading the PGF Manual helps ;). See page 54ff, I made this from it: \documentclass[parskip]{scrartcl} \usepackage[margin=15mm]{geometry} \usepackage{tikz} \usetikzlibrary{calc,intersections,through,backgrounds} \begin{document} \begin{tikzpicture} \coordinate (A) at (0,0); \coordinate (B) at (3,3); \draw [name path=A--B] (A) -- (B); \coordinate (C) at ...


14

The basic idea is to use a double line, with a white border. The problem is the default way tikz draws this is to draw the path completely a first time (the white border) and then completely a second time. The way around this is to use a decoration, more specifically the "show path construction" decoration. This decorates the path piecewise. The code is ...


14

You can use the intersections library: \documentclass{article} \usepackage{tikz} \usetikzlibrary{intersections} \pagestyle{empty} \begin{document} \begin{tikzpicture} \node (A) at (0,0) {1}; \node (B) at (1,0) {2}; \node (C) at (5,3) {3}; \node (D) at (-2,7) {4}; \draw[cyan,name path=d1] (A.center) -- (C.center); \draw[cyan,name path=d2] (B.center) ...


13

Here's one possible approach that uses a TikZ style. You insert the angle symbol by using the style right angle symbol={<Point 1>}{<Point 2>}{<Point 3>} in a draw command. If you want the angle symbol on its own, just use it in a new draw command: \draw [right angle symbol={<Point 1>}{<Point 2>}{<Point 3>}]; The ...


13

You made a mistake here (I removed the unknown styles) \draw[,thick] (S_21L) -- (S_22L) node[right] (S_22L) {$S_2$}; You need to remove the last (S_22L) \draw[, thick] (S_21L) -- (S_22L) node[right] {$S_2$}; You move the the coordinates (S_22L) with node[right] and S_22L) now is not on the line. \documentclass{scrartcl} \usepackage{tikz} ...


13

You can use name path global instead of name path to make the paths available for finding the intersections in a different scope. Note that you shouldn't use name intersection like a macro with \tikz, but instead use it as an option in a \path command (or similar). As percusse pointed out, instead of using name path global you can also find the intersection ...


13

or \documentclass[border=3pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \def\firstellip{(0, 1.6) ellipse [x radius=4cm, y radius=1.5cm, rotate=90]} \\ \def\secondellip{(2.9, -0.25) ellipse [x radius=4cm, y radius=1.5cm, rotate=29]} \def\thirdellip{(2, -3.5) ellipse [x radius=4cm, y radius=1.5cm, rotate=-57]} ...


12

Each plot is drawn in its own scope, so the named paths won't be known outside the \addplot command. In this case, you should use the name path global option instead of name path: \documentclass{standalone} \usepackage{pgfplots} \usetikzlibrary{intersections} \begin{document} \newcommand*{\ShowIntersection}{ \fill [name intersections={of=GraphCurve ...


11

In order to get the corner right, the path should be drawn in a single \draw command. You can still use the intersection of in this: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[line width = 4] \coordinate (a) at (0,0); \coordinate (b) at (1,0); \coordinate (c) at (1,1); \draw (a) -- (intersection of a--b and b--c) -- (c); ...


11

As wh1t3 said in the comment, you can extract the coordinate using \pgfgetlastxy{<macro for x>}{<macro for y>}. In order to transform this into axis units, you have to apply the inverse of the coordinate transformation that PGFplots uses. In the example below, I've wrapped the transformation in a macro \transformxdimension, which takes a length ...


11

The problem is due to how pgf tracks items between runs using the .aux file, and how this interacts with your particular situation. On the first run, there is no .aux file and so no issues. During this first run, pgf writes a number of lines of the form \pgfsyspdfmark {pgfid<id>}{<x>}{<y>} to the .aux file. These are used to track items ...


11

Not a direct answer to the question, but rather a suggestion of a different approach: If you use PGFplots and treat your lines as proper functions, you can plot the convex function simply using \addplot {min(f,g,h,i)};: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture}[/pgf/declare function={ f=tan(60)*x+1.7; ...


11

Using the fillbetween library that was introduced in PGFPlots 1.10: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usepgfplotslibrary{fillbetween} \usetikzlibrary{intersections} \pgfmathdeclarefunction{normal}{2}{% \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}% } \makeatletter \pgfmathdeclarefunction{erf}{1}{% ...


10

You can access the values of xmin, xmax, etc. through \pgfkeysvalueof{/pgfplots/xmin}. This only works if they have been set explicitly in the axis options, though, so it is most likely not what you want. Instead, you should use the nodes current axis.above origin, current axis.below origin, current axis.left of origin and current axis.right of origin. ...


10

I was going to say that this is just what the knots TikZ library is for, except that in testing it then I found that it didn't cope well with rounded corners. Fortunately, it was a quick fix but it does mean you'd need the spath3.dtx file from TeX-SX Launchpad instead of CTAN (don't be fooled by the existence of knot.dtx or spath.dtx, you want spath3.dtx ...


9

Another possibility is to use my package tkz-euclide (now on ctan and texlive 2011) but you don't need to get all the objects that I defined. Only angles are necessary. I take the Jake's example to show you that you can mix tikz and tkz. \usetkzobj{angles} this macro loads all the macros for the angles, if you need other objects \usetkzobj{angles,polygons} ...


8

I try the idea of whlt3 but it's was not easy; see the next code (perhaps I do some wrong things because I don't know very well pgfplots). I try also \pgfextractx. I need in each case to use \pgfextra to get the x component. Update with the excellent answer of Jake : \documentclass{minimal} \usepackage{tikz,pgfplots} \usetikzlibrary{intersections} ...


8

I like Jake's solution. However, if for some weird reason you don't want to use pgfplots you can use the name intersections approach. That would look like this: \documentclass{article} \nonstopmode \usepackage{tikz} \usetikzlibrary{calc,intersections} \begin{document} \begin{tikzpicture}[scale=.5] \draw[-stealth] (0,0) -- (10,0) node [below right] ...


8

You may use \pgfextra{\xdef\Nb{\t}} or \pgfextra{\global\let\Nb\t}: \documentclass[tikz]{standalone} \usetikzlibrary{intersections} \begin{document} \begin{tikzpicture} \clip (-2,-2) rectangle (2,2); \draw [name path=curve 1] (-2,-1) .. controls (8,-1) and (-8,1) .. (2,1); \draw [name path=curve 2] (-1,-2) .. controls (-1,8) and (1,-8) .. (1,2); ...


8

I don’t know why PGF doesn’t find these intersections, it probably has do to something with how the path is built internally from the points of the table of values gnuplot creates. It works if you either set set samples 100 or use—with the original samples setting—the smooth option. All intersections are found now. The of key ...


8

The main problem was that step was too small to be recognized by the intersections library (some ideas are written in the comment section). We also needed to correct a coefficient of 1.1 to get arrowheads back on the curve. The presented layout is in a way similar to this one, http://i.stack.imgur.com/mcmob.png. %! *latex mal-helicoid.tex ...


7

The problem seems to be that the brackets around P1 and P2 throw the foreach parser off: \i contains (P1) and (P2), not 1 and 2. You can fix this by removing the brackets: \documentclass[border=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{intersections} \begin{document} \begin{tikzpicture} \coordinate (P1) at (60:4cm); ...


7

I used Paul Gaborit's invclip style from his answer to How can I invert a 'clip' selection within TikZ?: \documentclass{article} \usepackage{tikz} \usetikzlibrary{intersections,positioning} \tikzset{invclip/.style={clip,insert path={ (-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt) }}} \begin{document} ...


7

Here's one possibility using the intersections library from TikZ: \documentclass{article} \usepackage{tikz} \usetikzlibrary{intersections} \newcommand\tikzmark[1]{% \tikz[remember picture,overlay]\node[inner xsep=0pt,inner ysep=10pt,outer sep=0pt] (#1) {};} \begin{document} \[ \tikzmark{c}2:\tikzmark{a}3 + 5:\tikzmark{d}3+\tikzmark{b}2:3+5:3 \] ...


7

This is going to be a very long answer (both in length and detailedness). Keep calm and keep reading. :) How to access a coordinate on a circle/an ellipse: polar coordinates While you can access a coordinate on a circle (or an ellipse with different radii) by using ({<x radius> * cos(<angle>)}, {<y radius> * sin(<angle>)}) TikZ ...


7

Yes (intersection-1) is known, but there are two problems in your code. If you remove them, your code compiles fine. 1) \tikz\name intersections={of=clipA and SpeciesA} ? why \tikz here and \name ? ?? 2) \clip [(0,0) -- (-30:25) -- (90:25) -- cycle; why the [( ? The next code compiles \documentclass{article} \usepackage{tikz} ...


7

A combination of surface colors, opacities and parametric plots can get you close to the desired result: Code follows: \documentclass{scrartcl} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[domain=0.01:30] \addplot3[surf, opacity=0.25, blue, shader=flat] {0}; \addplot3[surf, opacity=0.25] ...


6

Another hackish solution: \documentclass{scrartcl} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[domain=0.01:30] \addplot3[surf] {min(0.,(1-0.3)*e^(-x*(y/100)*(1-0.3))-e^(-x*(y/100))}; \addplot3[surf] {max(0.,(1-0.3)*e^(-x*(y/100)*(1-0.3))-e^(-x*(y/100)))}; \addplot3[domain=4:30,samples=80,samples y=0,mark=none,black, ...



Only top voted, non community-wiki answers of a minimum length are eligible