# Tikz Introduction

**Software for Exploratory Data Analysis and Statistical Modelling**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The **pgf** drawing package for **LaTeX** provides facilities for drawing simple of complicated pictures within a **LaTeX** document. There are many options available within the package and in this post we consider some of the basics to get up and running.

Fast Tube by Casper

As with all LaTeX documents we need to select a document class and include some preamble material prior to the body of our document. A blank template for a document with a single tikz picture is shown here:

\documentclass{article} \usepackage{tikz} \begin{document} \pagestyle{empty} \begin{tikzpicture} ... \end{tikzpicture} \end{document}

The tikz picture has a coordinate system similar to that which you would expect where moving from left to right on the page corresponds to increasing the x value and bottom to top increases the y value. A line can be drawn between two points wit the **\draw** command:

\draw (0,0) -- (1,0);

To draw a line between multiple points these can be chained together in a single draw command:

\draw (0,0) -- (1,0) -- (1, 4);

The line style can be altered by adding various options in square brackets directly after the draw command. So to change to a dashed red line we would write the following code:

\draw[red,dashed] (0,0) -- (2,0);

A circle of a given radius can be draw using the **\draw** command and we specify the radius of the circle in round brackets:

\draw (0,0) circle (2.5cm);

This will draw a circle with radius of 2.5 cm. The circle could be changed into an ellipse and we would then need to specify the radius in two directions, an example of this:

\draw (0,0) ellipse (2cm and 3.5cm);

Other useful resources are provided on the Supplementary Material page.

**leave a comment**for the author, please follow the link and comment on their blog:

**Software for Exploratory Data Analysis and Statistical Modelling**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.