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

Stylized earnings curve and fill in between them

$
0
0

It’s been so many days that I’m trying to create by the same way the curves of the figure below.

My code so far:

documentclass[a4paper]{article}
usepackage[english,greek]{babel}
usepackage{ucs} 
usepackage[utf8x]{inputenc}
usepackage{pgfplots}
usepackage{caption}
usetikzlibrary{intersections,patterns,pgfplots.fillbetween}

begin{document}
begin{tikzpicture}

  draw[->, very thick] (0,0) -- (7,0) node[pos=0.5,below,rotate=0]{Ηλικία};
  draw[->, very thick] (0,0) -- (0,7) node[pos=0.5,above,rotate=90]{Εισόδημα} ;
draw[brown, -, thick] (1,0) node[below]{18}--(1,.8); 
draw[brown, thick] (1,.8) to[out=90,in=180] (6,3.5) node[below]{footnotesize footnotesize begin{tabular}{c}Απόφοιτος\ β' βάθμιας Εκπαίδευσηςend{tabular} };
draw[blue, thick, -] (2,0) node[below] {22}--(2,2.3);
draw[blue, thick] (2,2.3) to[out=90,in=180] (6,6.8) node[below]{footnotesize footnotesize begin{tabular}{c}Απόφοιτος\ γ' βάθμιας Εκπαίδευσηςend{tabular} };
draw[dotted] (6,6.8) -- (6,0) node[below]{67};


end{tikzpicture}

end{document}

and what I would like to have
age-earnings

The parts that I’m struggling with are pointed out with the yellow line:
enter image description here


How to use tikzpicture with tabular

$
0
0

I’m trying to place my graphs into the same figure vertically. However, I couldn’t use tabular with tikzpicture to do it.

begin{figure}[]
  begin{center}
    begin{tikzpicture}[scale=0.9]
      begin{axis}[
          width=linewidth, % Scale the plot to linewidth
          height=0.5linewidth,
          grid style={dashed,gray!60},
          ylabel=Performance gain/drop percentage,
          yticklabel={pgfmathprintnumbertick%},
          legend style={at={(1,0)},anchor=south east},
          xticklabels={,,},
          xlabel=Something
        ]
        addplot[smooth,color=orange,mark=x,thick] 
        table[x=index,y=data,col sep=semicolon] {C2.csv};
        addplot[smooth,color=blue,mark=*,thick] 
        table[x=index,y=data,col sep=semicolon] {C2.csv};
        legend{Something}
      end{axis}
    end{tikzpicture}
    caption{Something}
    label{figure_2_s}
  end{center}
end{figure}

begin{figure}[]
  begin{center}
    begin{tikzpicture}[scale=0.9]
      begin{axis}[
          width=linewidth, % Scale the plot to linewidth
          height=0.5linewidth,
          grid style={dashed,gray!60},
          ylabel=Performance gain/drop percentage,
          yticklabel={pgfmathprintnumbertick%},
          legend style={at={(1,0)},anchor=south east},
          xticklabels={,,},
          xlabel=Something
        ]
        addplot[smooth,color=orange,mark=x,thick] 
        table[x=index,y=data,col sep=semicolon] {C4.csv};
        addplot[smooth,color=blue,mark=*,thick] 
        table[x=index,y=data,col sep=semicolon] {C4.csv};
        addplot[smooth,color=gray,mark=o,thick] 
        table[x=index,y=data,col sep=semicolon] {C4.csv};
        legend{Something}
      end{axis}
    end{tikzpicture}
    caption{Something}
    label{figure_4_s}
  end{center}
end{figure}

Plotting piecewise functions with TikZ

$
0
0

I would like to use TikZ package in LaTeX to draw the following piecewise functions and their graphs:

  1. f:[0, infty)rightarrow mathbb{R} such that f(0)=1, f(x)=0 if x>0;

  2. g:[0, 1]times[0, 1]rightarrow mathbb{R} such that g(x,1)=1 if 0<x<1 and
    g(x, y)=0 otherwise;

  3. G_f={(x,lambda): f(x)leq lambda}; and

  4. G_g={(x, y, lambda): g(x, y)leq lambda}.

Can anyone help in drawing this kind of graph?

$
0
0

Can anyone help in drawing the graph of the kind shown in figure with edge intersections? I struggled with pstricks and started to learn tikz but not able to do it. Kindly help as am not getting how to use points or co-ordinates so that I can draw a dashed edge intersecting already existing edge. Any package is ok.

enter image description here

Dealing with overlapping vectors tikz

$
0
0

The following produces undesirable output because the “tails” of the vectors are overlapping and hard to see. Is there a way to automate something better by having all vectors draw only 95% of their distance?

Is there an even a better solution than the one I prescribed?

Additionally, how can one swap up the arrowhead -> for a closed arrow -|>?

begin{tikzpicture}[scale=1.5]
%tkzInit[xmin=-3,xmax=7,ymin=-6,ymax=5] tkzGrid
tkzInit

tkzDefPoint(0,0){A}
tkzDefPoint(4,0){B}
tkzDefPoint(5,-3){C}
tkzDefPoint(1,-3){D}

draw[thick,->] (A) -- (B) node[above] {$B$};
draw[thick,<-] (B) -- (C) node[below] {$C$};
draw[thick,<-] (C) -- (D) node[below] {$D$};
draw[thick,->] (D) -- (A) node[above] {$A$};

tkzDefMidPoint(B,D) tkzGetPoint{E}
draw[thick,->] (D) -- (E) node[above] {$E$};
draw[thick,->] (C) -- (E);
draw[thick,->] (E) -- (A);
draw[thick,->] (E) -- (B);

end{tikzpicture}

enter image description here

Text on rectangular spiral with automatic sizing to fill page

$
0
0

I’m wondering how this could be done in TeX:

enter image description here

This is along the lines of Text spirals with TikZ but in a rectangle, with all text the same size, and all text should be at right angles (unlike the above example, where some letters at corners are not.)

Needs to be dynamic as I’m trying to get a whole lot of text on one letter-sized page – think for example a page filled up with text in 7-point font – and have the text fill the entire page (and never overflow onto other pages), no matter how much text exists.

Here’s an algorithm in python that gives the kind of rectangular spiral I’m talking about:

def spiral(X, Y):
    x = y = 0
    dx = 0
    dy = -1
    for i in range(max(X, Y)**2):
        if (-X/2 < x <= X/2) and (-Y/2 < y <= Y/2):
            print (x, y)
            # DO STUFF...
        if x == y or (x < 0 and x == -y) or (x > 0 and x == 1-y):
            dx, dy = -dy, dx
        x, y = x+dx, y+dy

Standard timeline with different circle colors

$
0
0

I just saw this amazing post and I was wondering if there was a slight addendum which could be used to make some of the circles in a different color. I also wanted to be able to modify the length of the whole arrow. This question should be a comment but I don’t have enough reputation to do so. The MWE is provided in the link.

Drawing elliptical arc with desired major and minor axis

$
0
0

So I am given two points and wish to draw an elliptical arc joining them. More specifically, my code is as follows:

documentclass{article}
usepackage{tikz}
begin{document}
begin{figure}[H]
centering
begin{tikzpicture}
[vertex/.style={circle,draw=black!100,fill=black!100,thick,inner sep=0pt,minimum size=1mm},]
node (v1) at ( 0,0) [vertex,label=left:$v_1$] {};
node (v2) at ( 1,0) [vertex,label=right:$v_2$] {};
node (v3) at ( 1.35,1) [vertex,label=right:$v_3$] {};
node (v4) at ( 0.5,1.75) [vertex,label=above:$v_4$] {};
node (v5) at ( -0.35,1) [vertex,label=left:$v_5$] {};
draw [-] (v1) to (v2);
draw [-] (v2) to (v3);
draw [-] (v3) to (v4);
draw [-] (v4) to (v5);
draw [-] (v5) to (v1);
draw [-] (v3) to (v1);
%draw [-] (v2) to [bend left=60] (v5);
end{tikzpicture}
end{figure}
end{document}

I wish to connect v2 to v5 and v2 to v4 without any intersection of edges. Now this is only possible if we draw elliptical arcs outside the pentagon. How can I draw those? I am unable to utilise bend left as it is not bending enough to go out of the pentagon.


Color Mixing/Overlapping Mechanism

$
0
0

Ideally I would imagine that if I overlap the red, yellow, blue three glasses, then I would see more or less a black color in the overlapped region.

However by doing this in LaTeX, it seems I was wrong, the overlapped region is colored by last color I use, regardless the opacity I use. Please see the following MWE and you will get what I mean.

My question is hence, what is the mechanism behind latex rendering overlapped colors? Why there is no mixing effect by using overlap?

MWE

% !TEX TS-program = xelatex 
documentclass[class=article,border=0pt]{standalone}
usepackage{tikz}

begin{document}
begin{tikzpicture}
node [circle, fill=blue, opacity=0.5, minimum size=.4cm] at (0.2cm,0cm) () {};
node [circle, fill=red, opacity=0.5, minimum size=.4cm] at (0cm,0cm)  () {};
node [circle, fill=yellow, opacity=0.5, minimum size=.4cm] at (0.1cm,0.2cm)  () {};
end{tikzpicture}
end{document}

How to use Tikz and macros to very efficiently draw recombining binomial trees when taking notes during class

$
0
0

For a class in derivatives pricing I would like to find a way to quickly and efficiently draw recombining binomial trees. The class involved quite a few of those trees and it would be immensely helpful to come up with a way that would allow me to semi-automate the process.

Here’s an example (excuse the low resolution; it’s the best I’ve been able to find):
enter image description here

I want to achieve this look by specifying only the number of periods (i.e. horizontal levels); the probability p of going upwards from any node; and the possible values for all nodes. The probabilities p and 1-p should then automatically be displayed above the connecting lines upwards and downwards respectively (as shown in the example). All values for the nodes themselves should be entered manually and their number of course depends on the number of levels.

I am of aware of the possibility of specifying node locations manually in order to achieve the recombining tree but my experience does not suffice to build something to automate this. My question is not about drawing recombining trees in general; it is about finding a way to do it very quickly, as I use LaTeX for my lecture notes.

Labels close to pie chart figures

$
0
0

I am trying to crate two pie charts side by side using tikz. I’ve found a code in the web that I am adapting, and so far, it seems to work. However, instead of using a separate legend below, I would like to insert the series labels close to the figures % in the charts. Would someone knows how can I modify the code below in order to achieve it?

Thanks in advance for any help with that.

documentclass[twoside,a4paper,12pt]{report}

usepackage{tikz}
usetikzlibrary{chains,positioning,shapes.symbols}

%define each color I want to use for each country/slice
definecolor{Australia} {RGB} {47,117,181}
definecolor{Brazil} {RGB} {0,176,80}
definecolor{Canada} {RGB} {244,176,132}
definecolor{China} {RGB} {191,143,0}
definecolor{France} {RGB} {155,194,230}
definecolor{Germany} {RGB} {198,89,17}
definecolor{Greece} {RGB} {221,235,247}
definecolor{Guinea} {RGB} {255,0,255}
definecolor{Guyana} {RGB} {255,217,102}
definecolor{Hungary} {RGB} {198,224,180}
definecolor{India} {RGB} {248,203,173}
definecolor{Indonesia} {RGB} {146,208,80}
definecolor{Ireland} {RGB} {255,217,0}
definecolor{Jamaica} {RGB} {131,60,12}
definecolor{Japan} {RGB} {31,78,120}
definecolor{Middle East} {RGB} {84,130,53}
definecolor{Norway} {RGB} {255,255,0}
definecolor{Russia} {RGB} {255,0,0}
definecolor{Suriname} {RGB} {112,48,160}
definecolor{UK} {RGB} {204,51,0}
definecolor{USA} {RGB} {0,0,255}
definecolor{USSR} {RGB} {255,0,0}
definecolor{Others} {RGB} {166,166,166}



tikzstyle{chart}=[legend label/.style={font={scriptsize},anchor=west,align=left},
    legend box/.style={rectangle, draw, minimum size=5pt},
    axis/.style={black,semithick,->},
    axis label/.style={anchor=east,font={tiny}},]

tikzstyle{pie chart}=[chart,
    slice/.style={line cap=round, line join=round, very thick,draw=white},
    pie title/.style={font={bf}},
    slice type/.style 2 args={
        ##1/.style={fill=##2},
        values of ##1/.style={}}]

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


newcommand{pie}[3][]{
    begin{scope}[#1]
    pgfmathsetmacro{curA}{90}
    pgfmathsetmacro{r}{1}
    defc{(0,0)}
    node[pie title] at (90:1.5) {#2};
    foreach v/s in{#3}{
        pgfmathsetmacro{deltaA}{v/100*360}
        pgfmathsetmacro{nextA}{curA + deltaA}
        pgfmathsetmacro{midA}{(curA+nextA)/2}

        path[slice,s] c
            -- +(curA:r)
            arc (curA:nextA:r)
            -- cycle;
        pgfmathsetmacro{d}{max((deltaA * -(.5/50) + 1) , .5)}

        begin{pgfonlayer}{foreground}
        path c -- node[pos=d,pie values,values of s]{$v%$} +(midA:r);
        end{pgfonlayer}

        globalletcurAnextA
    }
    end{scope}}

newcommand{legend}[2][]{
    begin{scope}[#1]
    path
        foreach n/s in {#2}
            {
                  ++(0,-10pt) node[s,legend box] {} +(5pt,0) node[legend label] {n}
            }
    ;
    end{scope}
}

begin{document}

begin{figure}
centering
begin{tikzpicture}
[   pie chart,
    slice type={Australia}{Australia},
    slice type={Brazil}{Brazil},
    slice type={Canada}{Canada},
    slice type={China}{China},
    slice type={France}{France},
    slice type={Germany}{Germany},
    slice type={Greece}{Greece},
    slice type={Guinea}{Guinea},
    slice type={Guyana}{Guyana},
    slice type={Hungary}{Hungary},
    slice type={India}{India},
    slice type={Indonesia}{Indonesia},
    slice type={Ireland}{Ireland},
    slice type={Jamaica}{Jamaica},
    slice type={Japan}{Japan},
    slice type={Middle East}{Middle East},
    slice type={Norway}{Norway},
    slice type={Russia}{Russia},
    slice type={Suriname}{Suriname},
    slice type={UK}{UK},
    slice type={USA}{USA},
    slice type={USSR}{USSR},
    slice type={Others}{Others},
    pie values/.style={font={small}},
    scale=2
]
    pie[xshift=0cm,values of Australia/.style={pos=1.2},values of Jamaica/.style={pos=1.2},values of Suriname/.style={pos=1.2},values of USSR/.style={pos=1.2},values of France/.style={pos=1.2},values of Greece/.style={pos=1.2},values of Guinea/.style={pos=1.2},values of Guyana/.style={pos=1.2},values of Hungary/.style={pos=1.2},,values of Others/.style={pos=1.2}]%
    {1972}{20/Australia,18/Jamaica,10/Suriname,11/USSR,5/France,3/Greece,4/Guinea,5/Guyana,3/Hungary,21/Others}

    pie[xshift=4cm,values of Australia/.style={pos=1.2},values of Brazil/.style={pos=1.2},values of China/.style={pos=1.2},values of Indonesia/.style={pos=1.2},,values of Guinea/.style={pos=1.2},values of India/.style={pos=1.2},values of Jamaica/.style={pos=1.2},values of Russia/.style={pos=1.2},values of Others/.style={pos=1.2}]%
    {2010}{32/Australia,15/Brazil,14/China,11/Indonesia,8/Guinea,6/India,4/Jamaica,3/Russia,7/Others}

    legend[shift={(-2cm,-1.5cm)}]{{Australia}/Australia,{Brazil}/Brazil,{China}/China}
    legend[shift={(-0.5cm,-1.5cm)}]{{France}/France,{Greece}/Greece,{Guinea}/Guinea}
    legend[shift={(1cm,-1.5cm)}]{{Guyana}/Guyana,{Hungary}/Hungary,{India}/India}
    legend[shift={(2.5cm,-1.5cm)}]{{Indonesia}/Indonesia,{Jamaica}/Jamaica,{Russia}/Russia}
    legend[shift={(4cm,-1.5cm)}]{{Suriname}/Suriname,{USSR}/USSR,{Others}/Others}
end{tikzpicture}
end{figure}

end{document} 

Background not aligning

$
0
0

I have following document

documentclass[a4paper,12pt]{report}
usepackage[left=1.5in,right=1in,top=1in,bottom=1in,
 includefoot,heightrounded]{geometry}
usepackage{graphicx}
usepackage{xcolor}
usepackage[document]{ragged2e}
usepackage{multicol}
usepackage{fancyhdr}    
usepackage{etoolbox}
usepackage{tikz}
usetikzlibrary{shapes,arrows,backgrounds,shadows,calc}

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

newcommand{newframe}[0]
{   begin{tikzpicture}[remember picture,overlay]
    begin{pgfonlayer}{background}
    draw [black,even odd rule] ($(current page.north
    west)+(1.5in,-1in)$) rectangle ($(current page.south east)+(-1in,1in)$);
    draw [black,even odd rule] ($(current page.north
    west)+(1.45in,-0.95in)$) rectangle ($(current page.south east)+(-0.95in,0.95in)$);
    end{pgfonlayer}
    end{tikzpicture}
}

patchcmd{chapter}{thispagestyle{plain}}{thispagestyle{fancy}}{}{}

begin{document}
newframe
input{file1.tex}
pagenumbering{gobble}

newpage
newframe
input{file2.tex}
pagenumbering{gobble}
end{document}

I am unable to put background layer (i.e. two rectangular borders) in background. What is wrong with my code?
I am using texlipse in eclipse and miktex with pdflatex

Desired output is to put two square rectangles around page. Since i have lots of file1, file2 i would really appreciate if input command stays there.

Draw acos(1/x) in tikz

$
0
0

I’d like to draw the graph of y=acos(1/x) using TIKZ. I don’t want pgfplot nor do I want pstricks. I want to do it strictly in TIKZ. Here is my attempt. I want to eventually draw on the domain [1,4], but for the moment I am using [1,1.1], otherwise you can’t see the rest of my plot.

begin{center}
begin{tikzpicture}
draw[->](-4,0)--(4,0) node[right]{$x$};
draw [->](0,0)--(0,pi) node[above]{$y$}; 
draw[red,dashed] (-4,pi/2)--(4,pi/2);
foreach x in {-3,-2,-1,1,2,3} draw (x,-3pt)--(x,3pt);
draw (-3,0) node[below]{$-3$};
draw (3,0) node[below]{$3$};
foreach y in {pi/2,pi} draw (-3pt,y)--(3pt,y);
draw (0,pi/2) node[left]{$dfrac{pi}{2}$};
draw (0,pi) node[left]{$pi$};
draw[thick,blue,->] plot [domain=1:1.1] (x,{acos(1.0/x)});
end{tikzpicture}
end{center}

The resulting image.

enter image description here

I don’t know what is happening here, because the plot should approach the horizontal asymptote $y=pi/2$.

Any thoughts?

Horizontal grid lines

$
0
0

I have a problem with horizontal grid lines in a graph (I am trying to overlay a 1cm x 1cm grid to my pages, and stumbled upon this in the process):

documentclass{standalone}
usepackage{tikz}
begin{document}   
tikz[]{%
    draw [help lines,red,ystep=1cm,xstep=1cm] (0,0) node{A} grid +(3cm, -3cm) node{B};
        }   
tikz[]{%
    draw [help lines,blue,ystep=1cm,xstep=1cm] (0,0) node{A} grid +(3cm, 3cm) node{B};
        }  
tikz[]{%
    draw [help lines,green,ystep=-1cm,xstep=1cm] (0,0) node{A} grid +(3cm, -3cm) node{B};
        }
end{document}

with this result:

three strange grids

Notice that the green grid has a negative ystep as suggested in Grid missing horizontal lines, but still I have no lines.

So I decided that I probably do not understand how grids are generated; can someone shed some light here?

How to get the random seed used in a tikzpicture?

$
0
0

I have a picture with randomly placed nodes. Sometimes the figure is nicer than other, and in the final version of the document, I’d like to have a nice figure.

I’d like to know how to get the seed used in each rendering of the figure and display it, so that I may use it with pgfmathsetseed{}. I know I could manually try a bunch of different values myself and set it myself in the end, but this is a fallback solution.

Below is a sample code, the part of the figure that looks nice or not nice depending on the random number generator’s seed.

resizebox{88mm}{!}{
 begin{tikzpicture}

draw (0,0)[very thick] ellipse (1.5cm and 2.25cm);

 foreach x in {1,2,...,80}{
    node (nodex) at (rand*1,rand*1.65) {$bullet$};
 }

 foreach list in {
{66,    26, 63, 11, 10, 20, 61, 55},
{24,    10, 31, 8,  66, 4,  72, 1},
%...
} {
    foreach i in list {
        foreach j in list {
             draw (nodei.center) -- (nodej.center);
        }
    }
 }

%...
%...

end{tikzpicture}
}

How can I get the seed used by the random number generator, without setting it myself?


Including graph using tikz causes not including bibliography file

$
0
0

I am experiencing problems using package tikz.
I have produced a graph in R and want to include it in my tex file using package tikz. After I include the the tex file with graph in myfile.tex with command include{histogram}, my bibliography.tex file is not included. If I remove the include{graph} command in myfile.tex, the bibliography is included again.
Does anybody know why this is happening?

the preambule in myfile.tex is

documentclass[titlepage,a4paper,oneside,12pt]{book}
usepackage{a4wide}
usepackage{lmodern} %lmodern nefungovalo bold kapitalky
usepackage{lipsum}
usepackage[slovak]{babel}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
usepackage{amsthm}
usepackage{url}
usepackage[unicode]{hyperref}
usepackage{tikz}
usepackage[top=30mm , bottom=30mm , left=35mm , right=20mm]{geometry}

usepackage{icomma} %desetinna carka bez mezery

usepackage{csquotes}

usepackage{fancyhdr}
renewcommandchaptermark[1]{markright{large{MakeUppercase{thechapter.  #1}}}}

fancypagestyle{plain}{%
fancyhf{} % clear all header and footer fields
fancyhead[R]{thepage}
renewcommand{headrulewidth}{0pt}
renewcommand{footrulewidth}{0pt}}


usepackage{setspace}

newcommand{txtsource}[1]{texttt{textit{#1}}}
setcounter{topnumber}{8}
setcounter{bottomnumber}{8}
setcounter{totalnumber}{8}



usepackage{tocloft}
renewcommandcftchapfont{largebfseries}
renewcommandcftsecfont{large}

renewcommandcftchappagefont{largebfseries}
renewcommandcftsecpagefont{large}

usepackage{indentfirst}
usepackage{parskip}
setlength {parskip }{6pt}
setlength {parindent }{1cm}
renewcommand{baselinestretch}{1.25}normalsize

DeclareQuoteStyle{czech} 
{quotedblbase}
 {textquotedblright}
  [0.05em]
  {textquoteleft}
{textquoteright}

Thanks!

Two timelines with tikzpicture?

$
0
0

I’m trying to create two timelines with tikzpicture. The top one looks as I want, but I’m having troubles with the bottom one. Instead of having little vertical tick marks I’m generating big diagonals.

documentclass{article}
usepackage[utf8]{inputenc}
usepackage{tikz}
usetikzlibrary{snakes}
usepackage{fullpage}
usepackage{graphicx}


begin{document}
resizebox{linewidth}{!}{% Resize table to fit within
begin{tikzpicture}[snake=zigzag, line before snake = 5mm, line after snake = 5mm]
%draw horizontal line
draw (0,0) -- (19/2,0);
draw[snake] (19/2,0) -- (25/2,0);
draw (25/2,0) -- (30/2,0);
draw[snake] (30/2,0) -- (35/2,0);
draw (35/2,0) -- (40/2,0);
%draw vertical lines
foreach x in {0, 5, 10, 19, 30, 40}{
   draw (x/2,3pt) -- (x/2,-3pt);
}
%draw nodes
draw (-2,0) node { PHYS1060 };

draw (0,0) node[below=3pt] { Pre-test published } node[above=3pt] { Jan 4, 2014  };
draw (5/2,0) node[below=3pt] { Nudge } node[above=3pt] { Jan 9, 2014  };
draw (10/2,0) node[below=3pt] { First class } node[above=3pt] { Jan 13, 2014  };
draw (19/2,0) node[below=3pt] { Pre-test due } node[above=3pt] { Jan 22, 2014  };
draw (30/2,0) node[below=3pt] { Midterm } node[above=3pt] { Feb 17, 2014  };
draw (40/2,0) node[below=3pt] { Final Exam} node[above=3pt] { May 5, 2014  };


%draw horizontal line
draw (-2,-2) node { PHYS1050 };
draw (0,-2) -- (19/2,-2);
draw[snake] (19/2,-2) -- (25/2,-2);
draw (25/2,-2) -- (30/2,-2);
draw[snake] (30/2,-2) -- (35/2,-2);
draw (35/2,-2) -- (40/2,-2);
draw vertical lines
foreach x in {0, 5, 10, 19, 30, 40}{
   draw (x/2,-2,3pt) -- (x/2,-2,-3pt);
}


%draw nodes
draw (0,-2) node[below=3pt] { Pre-test published } node[above=3pt] { Aug 10, 2014  };
draw (5/2,-2) node[below=3pt] { First class } node[above=3pt] { Aug 27, 2014  };
draw (10/2,-2) node[below=3pt] { Nudge } node[above=3pt] { Sept 4, 2014  };
draw (19/2,-2) node[below=3pt] { Pre-test due } node[above=3pt] { Sept 7, 2014  };
draw (30/2,-2) node[below=3pt] { Midterm } node[above=3pt] { ?, 2014  };
draw (40/2,-2) node[below=3pt] { Final Exam} node[above=3pt] { ?, 2014  };

end{tikzpicture}
}

end{document}

What am I doing wrong and how can I fix it?

Thanks!

Putting text at bottom of ellipse in a tikz picture

$
0
0

I have the following code:

documentclass[journal]{IEEEtran}
usepackage{tikz}
usetikzlibrary{shapes,backgrounds}

begin{figure}[ht]
begin{tikzpicture}
node[rounded corners, draw, fill=gray!20 ,text height = 5cm,minimum     width=9cm] (main){All Feasible Schedules};
node[ellipse, draw, fill=red!20, text height =3cm, minimum width = 8cm] at (main.center)  (semi) {Semi-Active Schedules};
node[ellipse, draw,fill=red!35, text height = 1.5cm, minimum width = 5cm] at (main.center) (active) {Active Schedules};
node[ellipse, draw, fill=red!42,align=left, anchor=east, xshift=-0.5cm ] at (active.east) (non) {Non-delay\Schedules};

end{tikzpicture}
end{figure}

Which gives:

enter image description here

How can I get the text semi-active schedules, and active schedules to nestle snugly at the bottom of their respective ellipses?

Adding arrows to rectangles in TikZ

$
0
0

Is it possible to decorate rectangles with arrows? I used:

node [draw,rectangle,minimum width=4cm,minimum height=4cm](r){};

But then it is really difficult to line up an edge so that it’s level with the edge of the rectangle, is there an easier way? I want it to look like:

enter image description here

Formatting node and edge labels in TikZ

$
0
0

In TikZ, how to format node and edge label (node and edge weight)? For example, how to make the edge weight in bold?

Viewing all 959 articles
Browse latest View live