Quantcast
Channel: Question and Answer » tikz-pgf
Viewing all 959 articles
Browse latest View live

TikZ doesn't find all intersections between plot and a line

$
0
0

Why doesn’t TikZ find all intersections. They are obviously there …

missing intersections

documentclass[border=10mm]{standalone}

usepackage{tikz}
usetikzlibrary{intersections}

begin{document}
begin{tikzpicture}[point/.style={fill=blue,minimum size=1mm,inner sep=0pt,circle}]
    % Zoom (to prevent oveflow)
    defyzoom{100}
    % Plots
    foreach T/xmin/a in {%
        0.27/1.538/a,
        0.28/1.590/b,
        0.29/1.649/c
    } {
        draw [thin,name path global/.expanded={kurve a}]
            plot [raw gnuplot] function {%
                set xrange [xmin:10];
                set yrange [0:0.08*yzoom];
                set samples 1000;
                f(x) = yzoom*(T/(x-1) - 1/(x**2));
                plot f(x);
            };
    }
    % Lines
    foreach p/a in {%
        %% T = 0.27
        0.0231/a,
        %% T = 0.28
        0.02855/b,
        %% T = 0.29
        0.0338/c
    }{
        draw [red,thin,name path global/.expanded={linie a}]
            (0,p*yzoom) -- (10,p*yzoom) node [fill=white,pos=0.1] {a};
    }
    % Intersections points
    path [name intersections={of=kurve a and linie a,by={P1,P2,P3}}]
        (P1) node [point] {} (P2) node [point] {} (P3) node [point] {};
    path [name intersections={of=kurve b and linie b,by={P1,P2,P3}}]
        (P1) node [point] {} (P2) node [point] {} (P3) node [point] {};
    path [name intersections={of=kurve c and linie c,by={P1,P2,P3}}]
        (P1) node [point] {} (P2) node [point] {} (P3) node [point] {};
end{tikzpicture}
end{document}

There seems to be no problem with the names of the paths but TikZ is missing four intersection points.

Bonus question: Is it possible to solve the last part (adding blue points) with the second foreach? I tried it but I get the error File ended while scanning use of tikz@intersect@path@names@parse..


Custom T shape in TikZ

$
0
0

I would to define a new “T” shape (i.e. the red and green shapes in the following image) so that I can then draw with TikZ the diagram below.

component

Unfortunately I cannot figure out how to do. To be honest, I have read the section “Declaring New Shapes” from the PGF manual and I am completely lost with the low level pgf commands.

How could I do? Suggestions on any direction are welcomed.

Combine Document Class and TikZ

$
0
0

I’m trying to combine several articles into a single volume using the combine document class. Some of the articles use the TikZ package, which seems to cause problems during compilation. For example, if my main file is

documentclass{combine}
usepackage{tikz}
begin{document}
begin{papers}
coltoctitle{Paper 1}
coltocauthor{A.~Author}
import{./author1/paper}
end{papers}
end{document}

and the document paper.tex in the directory author1 has the contents

documentclass{article}
title{My Paper}
author{A.~Author}
date{2013}
begin{document}
maketitle
My paper.
end{document}

then compiling the main document fails with the message ! TeX capacity exceeded, sorry [save size=5000]. But if I remove the TikZ package from the main document, then everything works fine. (Of course that’s not an option when the included file actually makes use of the package.) Short of manually converting all the TikZ pictures to image files, is there any way to fix this?

how to flip margin watermark in a two sided document

$
0
0

I have a problem that i didn’t figure out how to solve it.
I want that the background flips each time we turn the page.
This way pair pages will have the background margin on the left , and the impair pages will have the background margin photo at right.
I wish i was clear.

usepackage{background} %see the background doc for more info

backgroundsetup{%  
  scale=1,       
  angle=0,       
  opacity=.7,    
  color =black,  
  contents={begin{tikzpicture}[remember picture,overlay]
    node at ([yshift=0cm,xshift=-9.7cm]current page) {includegraphics[scale=1.10]{Margin.png}};    
end{tikzpicture}}  
}

Enabling “–shell-escape” on TeXworks under MiKTeX

$
0
0

After resolving the problem on my previous question, I applied to finally install Gnuplot 4.6; and after a successful installation I had to allow the --shell-escape option on TeXworks, so I added a new Typesetting Tool on the Preferences menu, called pdfLaTeX+ShellEscape.

The lines of code inserted into the tool configuration are listed below:

$synctexoption
-undump=pdflatex
--shell-escape
$fullname

The problem is that when I try to compile my MWE (MYname.tex) with the above specified option:

documentclass{article}
usepackage{pgfplots}
pgfplotsset{compat=newest}
%
begin{document}
begin{tikzpicture}
%
begin{axis}[no markers,samples=30]
addplot gnuplot{atanh(x)};
end{axis}
%
end{tikzpicture}
%
end{document}

I get this messge:

! Package pgfplots Error: Sorry, the gnuplot-result file 'MYname.pgf-plot.table'
could not be found. Maybe you need to enable the shell-escape feature? For 
pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke 
'>> gnuplot <file>.gnuplot' manually on the respective gnuplot file..

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help.
...                                              

l.7     addplot gnuplot{atanh(x)};
? 

I am running TeXworks 0.44, and until now it didn’t show this kind of stubbornness because I compiled every document without problems.

I did also some research and I found that I could write -enable-write18 but even after this try I get the same errmsg and so I’m stuck again with the plots problem (although I discovered a powerful program like Gnuplot I don’t know how to set LaTeX properly).

P.S. : Sorry for the deleted question with the same title, that issue was created by a simple human error.

Showing grid on top of plot fill with PGFplots?

$
0
0

I have a plot with a pass/fail metric, and wish to show this clearly by having to seperate colors in the plot. To make the data stand out, I have a background grid to the axis tick marks. However, this does not affect the fill I use to color the area under the plot, as this seems to be the top layer.

An example of what I have now is shown below:

Example image.

The code used to generate this is:

documentclass{article}
 usepackage{pgfplots, amsmath}
pgfplotsset{compat=newest}
pgfplotsset{major grid style={color=black}}
pgfplotsset{every  tick/.style={black,}}
pagestyle{empty}
begin{document}
begin{tikzpicture}
begin{axis}[ 
     xmin=5,
     xmax=55,
     ymin=0,
     tick align=outside,
     tickpos=left,
     xtick=data,
     ytick={0,0.2,...,2.5},
     enlargelimits=false,
     axis background/.style={fill=green!30},
     grid=both,
     xlabel=Frequency (MHz),
     ylabel=V$_{text{DD}}$ (V)]
addplot
[const plot, fill=red!30] 
coordinates
{
(5,0.7)
(10,0.8)
(15,0.9)
(20,1)
(25,1.1)
(30,1.2)
(35,1.3)
(40,1.4)
(45,1.5)
(50,1.6) 
(55,1.7)
} 
closedcycle;

end{axis}
end{tikzpicture}
end{document}

I want the gridlines to overlap the whole plot (meaning the fill as well). How can I achieve this?

Colored box around enumerate labels

$
0
0

I want a colored box around enumerate labels. My actual code is this:

documentclass{article}

usepackage{tikz}
usepackage{enumitem}

newcommand{fff}[1]{tikz
  node[
  inner sep=1.5pt,
  draw=blue,
  fill=blue,
  text=black,
  rounded corners=2pt]{#1};}

begin{document}
begin{enumerate}[label=fff{Alph*.}]
 item text
end{enumerate}

fff{A.}
end{document}

As you can see this code does not work. However the fff command works if not used inside the label specification.

Does anyone knows what is wrong with this code?

Global set node background

$
0
0

I know I can do this:

draw (5,0) node[above=3pt,fill=white,inner sep=0pt] {$5$}

But I wonder if it is possible to set the 3pt, fill=white, and inner sep=0pt globally for every node in my document?

Thanks.


TikZ – Why is the outer line of the grid way more bright than the grid itself?

$
0
0

Why does the outer line of the triangle grid (= the dark gray one) look so much more bright? It seems to get the same colour when I change draw=gray to draw=black, but that doesn’t make much sense to me (yet). Could someone explain please?

Picture with draw=gray

enter image description here

Picture with draw=black

enter image description here

MWE

documentclass[
11pt
]{scrartcl}

usepackage{
tikz,
relsize,
amsmath
}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}


%% from here on forth TikZ-stuff

usetikzlibrary{
calc,trees,shadows,positioning,arrows,chains,shapes.geometric,
decorations.pathreplacing,decorations.pathmorphing,shapes,
matrix,shapes.symbols,patterns,intersections,fit
}

pgfdeclarelayer{background layer}
pgfdeclarelayer{foreground layer}
pgfsetlayers{background layer,main,foreground layer}

tikzset{
>=latex
}

begin{document}
begin{center}
begin{tikzpicture}[font=sffamilysmall]
%N
draw[style=help lines,step=0.5cm] (0,0) grid (9,6);
%
draw[->,thick] (-0.1,0) -- (9.5,0) node[anchor=west]{Input};
draw[->,thick] (0,-0.1) -- (0,6.5) node[anchor=south]{Output}; 
%
foreach x in {0,1,...,9} draw [thick](x cm,-2pt) -- (x cm,2pt);
foreach y in {0,1,...,6} draw [thick](-2pt,y) -- (2pt,y);
%
foreach x in {0,1,...,9} draw (x cm, 0 cm) node[anchor=north]{x};
foreach y in {0,1,...,6}  draw (0 cm, y cm) node[anchor=east]{y};
draw
(2,1) coordinate (A)
(3,3) coordinate (B)
(3,2) coordinate (C)
(4,3) coordinate (D)
(5,4) coordinate (E)
(5,2) coordinate (F)
(6,3) coordinate (G)
(8,5) coordinate (H)
;
%%Cone
begin{pgfonlayer}{background layer}
draw[draw=gray,fill=gray,pattern=grid,draw opacity=0.6,fill opacity=0.6] (F) -- ($(F) + (-3.5,0)$) -- ($(F) + (0,3.5)$) -- cycle;
end{pgfonlayer}
%%Labels + Circles
foreach pt/labpos in {A/below right,B/below right,C/below right,D/below right,E/below right,F/below right,G/below right,H/below right}{
        filldraw (pt) circle(2pt) node[labpos=3pt,fill=white]{pt};
}
end{tikzpicture}
end{center}

end{document}

TikZ Matrix – How can I align content horizontally which is spanning over multiple cells/rows?

$
0
0

I’d like to finetune the big rectangle in the last column and its content, i.e. that it’s all aligned to the third column’s center. It is currently too far on the right:

enter image description here

So far I have been unable to find the missing option.

MWE

documentclass[
11pt
]{scrartcl}
usepackage{
tikz,
relsize,
tgheros
}

usetikzlibrary{
    calc,trees,shadows,positioning,arrows,chains,shapes.geometric,
    decorations.pathreplacing,decorations.pathmorphing,shapes,
    matrix,shapes.symbols,patterns,intersections%,fit
    }

pgfdeclarelayer{background layer}
pgfdeclarelayer{foreground layer}
pgfsetlayers{background layer,main,foreground layer}

tikzset{
    rolle/.style=
    {
        rectangle,
        drop shadow={opacity=0.5},
        minimum width=4em,
        minimum height=4em,
        text width=4cm,
        draw=black!80,
        very thick,
        fill=black!40,
        font=sffamilybfseries,
        align=center
    },
    einheit/.style=
    {
        rectangle,
        rounded corners, 
        minimum height=2em,
        minimum width=4em,
    draw=black!80,
        fill=black!20,
    font=sffamily
    },
}

begin{document}
begin{center}
begin{tikzpicture}[font=sffamilysmall,node distance=0.5cm]
    draw[thick] (-7.5,-4) rectangle (7.5,4);
    draw[thick,fill=black!20] (-7.5,4) rectangle (7.5,5) node[midway] {something};
    matrix (m) [matrix of nodes,nodes in empty cells,row sep=5mm,column sep=5mm] {
    %
    node[rolle] {123}; & node[rolle] {456}; & node[rolle] {789}; \
    %
    node[einheit] {words}; & & node[minimum width=5cm] (abc) {}; \
    %
    & node[einheit] {words}; & \
    %
    & node[einheit] {words}; & \
    %
    & node[einheit] {companies}; & \
    %
    node[einheit] {thing}; & & \
    };
    draw[einheit] (abc.north east) rectangle (m-6-3.south west) node[midway]{abc};
end{tikzpicture}
end{center}
end{document}

TikZ externalize fails to recognize changes [duplicate]

problems with tikz and arabi package

$
0
0

I have some problems and I hope you can help me.

When I put a tikzpicture and use the arabi package, the picture is not displayed in the dvi
or pdf file, and this without a single error.

I have a solution for that (which I don’t like), I have to put the TikZ picture inside
an english language environment, like this :

begine{otherlanguage}{english}
begin{tikzpicture}
...
...
end{tikzpicture}
end{otherlanguage}

it is a boring solution and not suitable if I want to create environments like boxed theorems, etc.

Here is a sample :

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

documentclass{report}


usepackage[Latin1, utf8, cp1256]{inputenc}
%usepackage[T1, OT1, LAE]{fontenc}
usepackage[english, arabic]{babel}
usepackage{amsmath, amsfonts, amssymb, amsthm}
usepackage{tikz}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Indian to Arabic Numerotations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
renewcommand{theenumi}{textLR{arabic{enumi}}-}
renewcommand{labelenumi}{theenumi}
renewcommand{theenumii}{alph{enumii})}
renewcommand{labelenumii}{theenumii}

renewcommand{theequation}{textLR{arabic{equation}}}

renewcommand{thesection}{textLR{arabic{section}} -}
renewcommand{thepage}{textLR{arabic{page}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


begin{document}

section{المتتاليات العددية}

tikzstyle{mybox} = [draw=red, fill=blue!20, very thick,
    rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
tikzstyle{fancytitle} =[draw=red, fill=blue!20, text=black, rectangle, rounded corners]
begin{otherlanguage}{english}
begin{tikzpicture}
node [mybox] (box){%
begin{minipage}{.89textwidth}
begin{otherlanguage}{arabic}     

لتكن $f$ دالة مستمرة على المجال $[a,b]$ و قابلة للإشتقاق على $]a,b[$, 
حيث $f(a)=f(b)$.
إذن, يوجد عدد حقيقي $c in ]a,b[$ حيث 
$$
f(c)=0
$$.
end{enumerate}
end{otherlanguage}
end{minipage}
};
node[fancytitle, left=10pt] at (box.north east) {AR{نظـريـة}};
node[fancytitle, rounded corners] at (box.east) {$clubsuit$};
end{tikzpicture}%
end{otherlanguage}

begin{center}
begin{otherlanguage}{english}
begin{tikzpicture}
draw[thick,rounded corners=8pt]
(0,0) -- (0,2) -- (1,3.25) -- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
end{tikzpicture}
end{otherlanguage}
end{center}


end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

you can try to compile this code with pdflatex without

begin{otherlanguage}{english}

end{otherlanguage}

in the last picture. this picture isn’t displayed in the output pdf file.

Vertical labeled markers

$
0
0

I have a plot with four curves, and I wish to add vertical marker to pinpint the exact moment the curve drops below a certain threshold, much like this:

enter image description here

I’d like to be able to control the width of the horizontal bar, as well as the label above it, and it should work on a logarithmic scale on the horizontal axis. How exactly do I do that?

remove drop shadow from one node

$
0
0

I have a beamer document with many complex trees, so I set defaults for colors, shadows, and so on. Is there a way to remove the drop shadow from a single node? E.g., in the following tree, suppose that Winesap apples should have no shadow. The closest I’ve come is with [drop shadow={fill=white,opacity=1}], but there’s still a faint gray outline of the shadow. And that outline is visible in xpdf, evince, mupdf, zathura, acroread, and even ImageMagick.

documentclass{beamer}
usecolortheme[named=teal]{structure}
usepackage{tikz}
usetikzlibrary{shadows,trees}
begin{document}

tikzset{edge from parent fork right,grow'=right,
every node/.style={rectangle,rounded corners,thick,draw=structure,fill=white,drop shadow},
edge from parent/.style={thick,draw=structure}}

begin{frame}
begin{tikzpicture}[level 1/.style={level distance=7em,sibling distance=9em},
        level 2/.style={level distance=7em,sibling distance=6em},
        level 3/.style={level distance=7em,sibling distance=3em}]
node {food}
child {node {fruit}
child {node {apples}
child {node {Granny Smith}}
child {node[drop shadow={fill=white,opacity=1}] {Winesap}}}
child {node {pears}}}
child {node {veggies}
child {node {beets}}
child {node {Swiss chard}}};
end{tikzpicture}
end{frame}
end{document}

enter image description here

No tick labels and adding title to groupplot generated plots

$
0
0

I am generating an array of plots using pgfplots and more specifically the groupplot environment. Here is an example:

begin{tikzpicture} 

begin{groupplot}[group style={group size=2 by 2,horizontal sep=0.2cm,vertical sep=0.2cm},height=3cm,width=3cm] 
nextgroupplot addplot coordinates {(0,2) (1,1) (2,1)};
nextgroupplot addplot coordinates {(0,2) (1,1) (1,0)}; 
nextgroupplot addplot coordinates {(0,0) (1,1) (2,2)};
nextgroupplot addplot coordinates {(0,2) (1,1) (2,0)};
end{groupplot}

end{tikzpicture}

I would like to be able to eliminate either the x or the y tick labels or both. I also want to add a different title to each plot. I have not found a way to do this in the documentation. Any ideas?


TikZ: position text along path

$
0
0

I’m trying to position a piece of text at a certain position along a multi-part path. Here’s what I have been trying so far.

documentclass[tikz]{standalone}

usepackage{tikz}
usetikzlibrary{decorations.markings}

begin{document}
begin{tikzpicture}[inner sep=0pt, outer sep=0pt]
  path[fill=red,even odd rule, postaction={decorate},decoration={markings,mark=at position .2 with {node (0,20) {my text};}}] (0,0) -- (5,5) -- (5,0);
end{tikzpicture}
end{document}

I would like the node to be rotated so that the text is aligned with the path at the position of the node. I can of course manually rotate the node, but I would like this to happen automatically.

Please Note: I know about decorations.text, which could achieve what I’m trying to do. The problem here is that I would need to specify exactly at which relative position the text should appear (for example at 20% of the path length). If you know a way how to achieve this using decorations.text – please go ahead and compile an answer. Otherwise, I’ll stick with this node marking hack.

Why isn't the arc drawn on the good plane using tikz-3dplot in Tait-Bryan convention

$
0
0

As some people on tex.sx, I used the tikz-3dplot and changed some commands to use Tait-Bryan convention instead of the default Euler convention.

As you can see on the following picture, the rotation works fine and the rotated xy-plane (magenta one) and the xz-plane (the black one) are drawn properly (each of them, centered in (0,0,0) touches the top of their two respective unit vectors.

The rotations

Nevertheless, the third plane, yz (the red one) is no on the good plane.

The workaround to draw this plane (the cyan one) was to make a 3d scope.

%Using directly the 3d library instead
tdplotsetrotatedcoords{yaw}{pitch}{roll}
begin{scope}[tdplot_rotated_coords,canvas is yz plane at x=0]
draw[dashed,cyan,->,thick]  (0:1) arc (0:350:1);
end{scope}

This clearly shows that the rotation does its work, it’s in the yz plane and the 0 stands on the y axis. The rotation is in the good direction.

So, this might be because of the redefinition of the thetaplane command :

%Instead of permuting the coordinates as does Jeff, I rotate the planes as in the previous command.
renewcommand{tdplotsetrotatedthetaplanecoords}[1]{%
  tdplotresetrotatedcoordsorigin
    tdplotsetrotatedcoords{tdplotalpha + #1}{tdplotbeta}{tdplotgamma+90}
}

So, am I doing something wrong ?

Anyway, there is my code with all the renewcommand :

documentclass{standalone}
usepackage{amsmath}
usepackage{amssymb}
usepackage{amsthm}
usepackage[usenames,dvipsnames]{xcolor}
usepackage{tikz}
usepackage{tikz-3dplot-mod}
usepackage{pgfplots}
usepgfplotslibrary{external} 

%You get back to Euler convention by commenting out the following lines.
%Redefine all the tikz-3dplot according to Tait-Bryan convention
%This performs the calculation to define the main coordinate frame orientation style, and is also used to transform a coordinate from the main coordinate frame the the screen coordinate frame
%In comparison to genuine tikz-3dplot, this changes the orientation, so z points downwards when turnen around x-axis by 90 degres
renewcommand{tdplotcalctransformmainscreen}{%
  %
    tdplotsinandcos{sintheta}{costheta}{tdplotmaintheta}%
    tdplotsinandcos{sinphi}{cosphi}{tdplotmainphi}%
    %
    tdplotmult{stsp}{sintheta}{sinphi}%
    tdplotmult{stcp}{sintheta}{cosphi}%
    tdplotmult{ctsp}{costheta}{sinphi}%
    tdplotmult{ctcp}{costheta}{cosphi}%
    %
    %determine rotation matrix elements for display transformation
    %it's line major meaning that rab_ is the  first line, second column
    pgfmathsetmacro{raarot}{cosphi}%
    pgfmathsetmacro{rabrot}{-sinphi}%
    %NOTE: rac is zero for this rotation, where z^c always points vertical on the page
    pgfmathsetmacro{racrot}{0}%
    pgfmathsetmacro{rbarot}{ctsp}%
    pgfmathsetmacro{rbbrot}{ctcp}%
    pgfmathsetmacro{rbcrot}{-sintheta}%
    %NOTE: third row of rotation matrix not needed for display since screen z is always flat on the page.  It is, however, needed when performing further transformations using the Euler transformation.
    pgfmathsetmacro{rcarot}{stsp}%
    pgfmathsetmacro{rcbrot}{stcp}%
    pgfmathsetmacro{rccrot}{costheta}%
    %
}

%determines the rotation matrix for transformation from the rotation coordinate frame to the main coordinate frame.  This also defines the rotation to produce the rotated coordinate frame.
%In comparison to genuine tikz-3dplot, it does a zyx rotation sequence according to Tait-Bryan convention.
renewcommand{tdplotcalctransformrotmain}{%
  %perform some trig for the Euler transformation
    tdplotsinandcos{sinalpha}{cosalpha}{tdplotalpha}
  tdplotsinandcos{sinbeta}{cosbeta}{tdplotbeta}
  tdplotsinandcos{singamma}{cosgamma}{tdplotgamma}
  %
    tdplotmult{sasb}{sinalpha}{sinbeta}
  tdplotmult{sasg}{sinalpha}{singamma}
  tdplotmult{sasbsg}{sasb}{singamma}
  %
    tdplotmult{sacb}{sinalpha}{cosbeta}
  tdplotmult{sacg}{sinalpha}{cosgamma}
  tdplotmult{sasbcg}{sasb}{cosgamma}
  %
    tdplotmult{casb}{cosalpha}{sinbeta}
  tdplotmult{cacb}{cosalpha}{cosbeta}
  tdplotmult{cacg}{cosalpha}{cosgamma}
  tdplotmult{casg}{cosalpha}{singamma}
  %
    tdplotmult{cbsg}{cosbeta}{singamma}
  tdplotmult{cbcg}{cosbeta}{cosgamma}
  %
    tdplotmult{casbsg}{casb}{singamma}
  tdplotmult{casbcg}{casb}{cosgamma}
  %
    %determine rotation matrix elements for Euler transformation
    pgfmathsetmacro{raaeul}{cacb}
  pgfmathsetmacro{rabeul}{casbsg - sacg}
  pgfmathsetmacro{raceul}{sasg + casbcg}
  pgfmathsetmacro{rbaeul}{sacb}
  pgfmathsetmacro{rbbeul}{sasbsg + cacg}
  pgfmathsetmacro{rbceul}{sasbcg - casg}
  pgfmathsetmacro{rcaeul}{-sinbeta}
  pgfmathsetmacro{rcbeul}{cbsg}
  pgfmathsetmacro{rcceul}{cbcg}
  %DEBUG: display euler matrix elements
    %raaeul rabeul raceul
    %
    %rbaeul rbbeul rbceul
    %
    %rcaeul rcbeul rcceul
}


%determines the rotation matrix for transformation from the main coordinate frame to the rotated coordinate frame.
%In comparison to genuine tikz-3dplot, it does a zyx rotation sequence according to Tait-Bryan convention.
%It's the transposed of the matrix calculated in tdplotcalctransformrotmain
renewcommand{tdplotcalctransformmainrot}{%
  %perform some trig for the Euler transformation
    tdplotsinandcos{sinalpha}{cosalpha}{tdplotalpha}
  tdplotsinandcos{sinbeta}{cosbeta}{tdplotbeta}
  tdplotsinandcos{singamma}{cosgamma}{tdplotgamma}
  %
    tdplotmult{sasb}{sinalpha}{sinbeta}
  tdplotmult{sasg}{sinalpha}{singamma}
  tdplotmult{sasbsg}{sasb}{singamma}
  %
    tdplotmult{sacb}{sinalpha}{cosbeta}
  tdplotmult{sacg}{sinalpha}{cosgamma}
  tdplotmult{sasbcg}{sasb}{cosgamma}
  %
    tdplotmult{casb}{cosalpha}{sinbeta}
  tdplotmult{cacb}{cosalpha}{cosbeta}
  tdplotmult{cacg}{cosalpha}{cosgamma}
  tdplotmult{casg}{cosalpha}{singamma}
  %
    tdplotmult{cbsg}{cosbeta}{singamma}
  tdplotmult{cbcg}{cosbeta}{cosgamma}
  %
    tdplotmult{casbsg}{casb}{singamma}
  tdplotmult{casbcg}{casb}{cosgamma}
  %
    %determine rotation matrix elements for Euler transformation
    pgfmathsetmacro{raaeul}{cacb}
  pgfmathsetmacro{rabeul}{sacb}
  pgfmathsetmacro{raceul}{-sinbeta}
  pgfmathsetmacro{rbaeul}{casbsg - sacg}
  pgfmathsetmacro{rbbeul}{sasbsg + cacg}
  pgfmathsetmacro{rbceul}{cbsg}
  pgfmathsetmacro{rcaeul}{sasg + casbcg}
  pgfmathsetmacro{rcbeul}{sasbcg - casg}
  pgfmathsetmacro{rcceul}{cbcg}
  %
    %DEBUG: display euler matrix elements
    %raaeul rabeul raceul
    %
    %rbaeul rbbeul rbceul
    %
    %rcaeul rcbeul rcceul
}

%tdplotsetthetaplanecoords{phi}
%this places the rotated coordinate system such that it's x'-y' plane coincides with a "theta plane" for the main coordinate system:  This plane contains the z axis, and lies at angle phi from the x axis.
%#1: user-specified phi angle from x-axis
%Since the rotation sequence changed, we also have to redefine the theta plane. We basically turns the zx-plane to the theta plane and flip the xy plane of 90° to make him coincide with the theta plane.
renewcommand{tdplotsetthetaplanecoords}[1]{%
  %
    tdplotresetrotatedcoordsorigin
    tdplotsetrotatedcoords{#1}{0}{90}%
}

%%tdplotsetrotatedthetaplanecoords{phi'}
%%this places the rotated coordinate system into the "theta plane" for the current rotated coordinate system, at user-specified angle phi'.  Note that it replaces the current rotated coordinate system
%%#1: user-specified phi' angle from x'-axis
%Instead of permuting the coordinates as does Jeff, I rotate the planes as in the previous command.
renewcommand{tdplotsetrotatedthetaplanecoords}[1]{%
  tdplotresetrotatedcoordsorigin
    tdplotsetrotatedcoords{tdplotalpha + #1}{tdplotbeta}{tdplotgamma+90}%
    %    message{DEBUG theta plane coords : #1 : racrc, rbcrc}
}

begin{document}

defroll{30}
defpitch{50}
defyaw{40}
defxMainRot{100}
defzMainRot{30}
tdplotsetmaincoords{xMainRot}{zMainRot}
begin{tikzpicture}[scale=4,tdplot_main_coords,every node/.append style={transform shape}]
%
draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south east]{$z$};
%
tdplotsetrotatedcoords{yaw}{pitch}{roll}
draw[thick,color=magenta,tdplot_rotated_coords,->] (0,0,0) -- (1,0,0) node[anchor=north]{$x$};
draw[thick,color=magenta,tdplot_rotated_coords,->] (0,0,0) -- (0,1,0) node[anchor=west]{$y$};
draw[thick,color=magenta,tdplot_rotated_coords,->] (0,0,0) -- (0,0,1) node[anchor=south west]{$z$};
%
%Drawing the three planes of the new frame
tdplotdrawarc[tdplot_rotated_coords,dashed,color=magenta]{(0,0,0)}{1}{0}{360}{anchor=north,transform shape}{}
tdplotsetrotatedthetaplanecoords{0}
tdplotdrawarc[tdplot_rotated_coords,dashed,color=black]{(0,0,0)}{1}{0}{360}{transform shape}{}
tdplotsetrotatedcoords{yaw}{pitch}{roll}
tdplotsetrotatedthetaplanecoords{90}
tdplotdrawarc[tdplot_rotated_coords,dashed,color=red]{(0,0,0)}{1}{0}{360}{transform shape}{}
%
%Using directly the 3d library instead
tdplotsetrotatedcoords{yaw}{pitch}{roll}
begin{scope}[tdplot_rotated_coords,canvas is yz plane at x=0]
draw[dashed,cyan,->,thick]  (0:1) arc (0:350:1);
end{scope}
%NOTE: the rotation does its work, it's in the yz plane and the 0 stands on the y axis and the rotation is in the good direction.
end{tikzpicture}
end{document}

tikz diamond node white space

$
0
0

I wonder how I can remove the white space between the diamond node and the link in the following MWE.

documentclass[10pt]{article}

usepackage{tikz}
usetikzlibrary{positioning,shapes,arrows}

usepackage[a4paper, margin=0.2in, includefoot]{geometry}

usepackage{fontspec,lipsum}
defaultfontfeatures{Ligatures=TeX}
setromanfont{Century Gothic}

begin{document}

tikzset{font=Large,
every node/.style=
    {rectangle,rounded corners,
    draw=black,
    very thick,
    align=center
    }}

begin{tikzpicture}[node distance = 2cm, auto]
node (a) {AAAAA};
node[diamond, below=of a] (R) {BBBBB};
node[below right=of R](d){CCCCC};
draw[->][ultra thick](R.east) -| node[above, draw=none,near start,yshift=0.1cm] {No} (d.north);
draw[->][ultra thick](a.south) -- (R.north);
end{tikzpicture}

end{document}

TikZ: showing a plane moving in 3 space

$
0
0

I have 2 identical planes a distance of Delta t apart. I want to show that first plane is being pushed in the direction of the second plane.

I was thinking maybe some randomly placed arrows tangent to the planes pointing from plane one to plane two.

  1. Would this be the way to go?
  2. How can I set up a foreach command and specify 5 random arrows starting in the area of the plane? That is, not passing through the first plane just touching it and moving away tangent to the plane.

Or is there a better way to show this?

documentclass[convert = false, tikz]{standalone}

usepackage[utf8]{inputenc}
renewcommand{rmdefault}{ppl}
linespread{1.05}
usepackage[scaled]{helvet}
usepackage{courier}
usepackage{eulervm}
normalfont
usepackage[T1]{fontenc}
usepackage{textcomp}

usepackage{amsmath}
usepackage{tikz-3dplot}

begin{document}
tdplotsetmaincoords{60}{130}
begin{tikzpicture}[tdplot_main_coords]
  coordinate (O) at (0, 0, 0);

  draw[-latex] (O) -- (5, 0, 0) node[font = small, pos = 1.1] {(x)};
  draw[-latex] (O) -- (0, 5, 0) node[font = small, pos = 1.1] {(y)};
  draw[-latex] (O) -- (0, 0, 4) node[font = small, pos = 1.1] {(z)};
  draw[dashed] (O) -- (-3, 0, 0);

  filldraw[blue, opacity = .6] (4, 0, 0) -- (4, 5, 0) -- (4, 5, 4) --
  (4, 0, 4) -- cycle;
  filldraw[blue, opacity = .6] (-2, 0, 0) -- (-2, 5, 0) -- (-2, 5, 4) --
  (-2, 0, 4) -- cycle;

  draw[latex-latex] (4, 5, 2) -- (-2, 5, 2) node[font = small, fill = white,
  inner sep = 0, pos = .5] {(Delta t)};
  draw[|-|] (4, 2.5, 4) -- (-2, 2.5, 4) node[font = small, fill = white,
  inner sep = 0, pos = .5] {(vDelta t)};
end{tikzpicture}
end{document}

enter image description here

pgfgantt: draw arrows (links) behind bars

$
0
0

I want to draw a Gantt diagram using pgfgantt. With the default settings, it draws the bars first and the arrows/links second. Thereby, the bars are crossed by the arrows which I find utterly ugly. Is it possible to change this behaviour, e.g., to define the z-order of drawing ?

enter image description here

Minimal working example:

documentclass{article}
usepackage{pgfgantt}

begin{document}
begin{tikzpicture}
begin{ganttchart}[bar/.append style={orange}, link/.append style={thick}]{1}{6}
  ganttbar{Task 1}{1}{2} \
  ganttbar{Task 2}{3}{4} \
  ganttbar{Task 3}{5}{6}
  ganttlink[link type=f-s]{elem0}{elem1}
  ganttlink{elem0}{elem2}
end{ganttchart}
end{tikzpicture}
end{document}

The example works with pgfgantt.sty version 4.0.

Viewing all 959 articles
Browse latest View live