- SmartDiagram
- TikZ
- PGFPlots
Introduction & SmartDiagram
Simple charts, drawings and diagrams
In this part of the graphics section we plan on covering
the basics of the following packages:
SmartDiagram
With that said, let's get right into business, starting off from the
top of our list with our first drawing package: "SmartDiagram".
As the name suggests, the aim of the package is to provide the user
with an easy way of drawing diagrams to use in presentations or text
documents. It is a pretty intuitive package and should not give many
issues during the learning process.
Note that the SmartDiagram package automatically loads the
TikZ, etoolbox, xparse, xtring packages along with the backgrounds,
calcs, fadings, shadows, shapes.arrows, shapes.symbols TikZ libraries.
The basic command to make diagrams is
The diagram types you can insert are the following:*
*Note that the following elements are written with capital letters for the sake of a better appearance. Every diagram type should be written without capital letters when used as actual code.
\smartdiagram[type of diagram]{item list}
where each item should be
separated by a comma.The diagram types you can insert are the following:*
*Note that the following elements are written with capital letters for the sake of a better appearance. Every diagram type should be written without capital letters when used as actual code.
- Circular Diagram: counterclockwise circular diagram by default
- Circular Diagram:clockwise: clockwise version of the previous diagram
- Flow Diagram: represents a flow chart
- Flow Diagram:horizontal: horizontal version of the previous diagram
- Descriptive Diagram: displays items and their descriptions
- Priority Descriptive Diagram: items are sorted by their relevance
- Bubble Diagram: each item is displayed as a bubble around a bubble center which contains the first element
- Constellation Diagram: each item is a circle connected to the center which is the first item of the list
- Connected Constellation Diagram: every item is a cirlce and they are all connected except for the first item
- Sequence Diagram: all the items are displayed in a sequence which points to the following element
\smartdiagramset{list of options}
command.
We'll list the general options here:
set color list (default: none)
: defines the list of usable colorsuniform color list (default: none)
: defines a single color for the diagramuse predefined color list (default: none)
: lets the user reuse the colors used in a previous diagraminsert decoration (default: none)
: allows the user to decorate the borders of the diagram module. This would require additional decoration packages so we won't cover it here. If you're interested, we reccomend to check out the documentation.arrow line width (default: 0.1cm)
: changes the width of the diagram arrowsarrow tip (default: stealth)
: allows to select the arrow tip. This requires more expertise and further libraries to work.arrow style (default: <-)
: selects the arrow styleuniform arrow color (default: false)
: when true, enables arrow colorarrow color (default: gray)
: selects the arrow color
Circular Diagram
The following example shows you how LaTeX compiles the basic
\smartdiagram[circular diagram]
command:
CODE
\documentclass[12pt]{article}
\title{Circular Diagram}
\date{}
\usepackage{smartdiagram}
\begin{document}
\maketitle
\begin{center}
\smartdiagram[circular diagram]{Item 1, Item 2, Item 3, Item 4}
\end{center}
\end{document}
This might be simple and effective but if it doesn't fit what you want
you might also want to check out options to customize your own diagram.
The specific options for this type of diagram also apply to the clockwise circular diagram,
to the flow diagram and its horizontal counterpart.
They are as follows:
module minimum width (default: 2cm)
: sets the minimum width of the modulemodule minimum height (default: 1cm)
: sets the minimum height of the modulemodule shape (default: rectangle, rounded corners)
:sets the shape of the module but you should ensure to load the correct library for shapestext width (default: 1.75cm)
:sets the text width inside the modulefont (default: \small)
: sets the font inside the moduleborder color (default: gray)
:sets the color of the module bordertext color
: sets the color of the text in the modulecircular distance (default 2.75)
: sets the radius of the circle which the items are placed onto
CODE
\documentclass[12pt]{article}
\title{Customized Circular Diagram}
\date{}
\usepackage{smartdiagram}
\begin{document}
\maketitle
\begin{center}
\smartdiagramset{
module minimum width=4cm,
module minimum height=2cm,
font= \huge,
border color= black,
text color= blue!30!green,
circular distance= 5}
\smartdiagram[circular diagram]{Item 1, Item 2, Item 3, Item 4}
\end{center}
\end{document}
This diagram is compiled using a few of the previously listed options.
We first begin the
As you can see our options were typed out as they are, nothing fancy or complex needed. Just follow it with an "=" sign and you're set for building your own diagram. The
center
environment to center the diagram in the middle
of our document, then we define the settings of our diagram with the command
\smartdiagram
, we list the options we wish to modify taking them from the available ones
and finally we draw our diagram with the \smartdiagram
command.
Take a look at the code above the pdf embed to get a grasp of how the
options and diagrams should be built in LaTeX. As you can see our options were typed out as they are, nothing fancy or complex needed. Just follow it with an "=" sign and you're set for building your own diagram. The
circular diagram:clockwise
works exactly the same,
it only flips the arrow direction.
Flow Diagram
First of all the flow diagram makes use of 4 more options that you can apply:
module y sep (default: 1.65)
: sets the vertical distance between modules in the flow diagrammodule x sep (default: 2.75)
: sets the horizontal distance between modules in the flow diagram horizontalback arrow distance (default: 0.5)
: sets the distance of the arrows from the modulesback arrow disabled (default: false)
: when set to true, it disables the back arrow
\smartdiagram[flow diagram]
command:
CODE
\documentclass[12pt]{article}
\title{Flow Diagram}
\date{}
\usepackage{smartdiagram}
\begin{document}
\maketitle
\begin{center}
\smartdiagram[flow diagram]{Item 1, Item 2, Item 3, Item 4}
\end{center}
\end{document}
Likewise, we are now going to introduce options to make this default
flow diagram our way:
CODE
\documentclass[12pt]{article}
\title{Customized Flow Diagram}
\date{}
\usepackage{smartdiagram}
\begin{document}
\maketitle
\begin{center}
\smartdiagramset{
uniform color list=black!50!white for 4 items,
module minimum width= 6cm,
module minimum height= 2cm,
module y sep= 3.5,
text color= blue,
font= \Large,
border color= red,
back arrow disabled= true}
\smartdiagram[flow diagram]{Item 1, Item 2, Item 3, Item 4}
\end{center}
\end{document}
We now used the additional flow diagram options to increase the vertical
distance between modules and disable the back arrow that points back to
the beginning of the diagram. Additionally we defined a uniform color
for the first 4 items.
Constellation Diagram
Bubble and Constellation diagrams have a more complex set of options as
they can be customized in more detail.
Here follows the list of new available options:
Here follows the list of new available options:
planet size (default 2.5cm)
: minimum size of the planetplanet color (default lightgray!60)
: background color of the planetplanet font (default \large)
: font size of the planetdistance planet-connection (default 0.1cm)
: distance between the planet and the connecting arrowdistance planet-text (default 0.5cm)
: distance between the planet text and its borderplanet text width (default 1.75cm)
: width of the planet textsatellite size (default 1.75cm)
: size of the satellitesatellite font (default: \normalfont)
: font size of the satellitesatellite fill opacity (default: 0.5)
: opacity of the satellite backgroundsatellite text opacity (default: 0.8)
: opacity of the satellite textsatellite text width (default: 1.5cm)
: width of the satellite textdistance satellite-connection (default: 0.075cm)
: distance between the satellite and the connecting arrowconnection line width (default: 0.1cm)
: allows the customization of the width of the connecting arrowdistance planet-satellite (default: 3.5cm)
: distance between the planet and a satelliteuniform connection color (default: false)
: when true, overrides the color list definition enabling theconnection color
commandconnection color (default: gray)
: allows to set a color for the connecting arrows
CODE
\documentclass[12pt]{article}
\title{Constellation Diagram}
\date{}
\usepackage{smartdiagram}
\begin{document}
\maketitle
\begin{center}
\smartdiagram[constellation diagram]{Item 1, Item 2, Item 3, Item 4, Item 5}
\end{center}
\end{document}
And now will follow a customized constellation diagram:
CODE
\documentclass[12pt]{article}
\title{Customized Constellation Diagram}
\date{}
\usepackage{smartdiagram}
\begin{document}
\maketitle
\begin{center}
\smartdiagramset{
planet size= 4cm,
planet color= green,
planet font= \huge,
distance planet-connection= 0.1cm,
distance planet-text= 1cm,
satellite size= 2cm,
satellite font= \large,
satellite text opacity= 0.9,
distance satellite-connection= 0.1cm,
connection line width= 0.5cm,
distance planet-satellite= 5cm,
uniform connection color= true,
connection color= black}
\smartdiagram[constellation diagram]{Item 1, Item 2, Item 3, Item 4, Item 5}
\end{center}
\end{document}
Constellation diagrams are more complex as you can see from the length of the code,
by using all of our options we managed to modify its default shape.
Most commands like size, font, color we have already seen. What you should watch out for
are the "distance" commands, those can get tricky if you miscalculate the space you're using.
Author's note: I'd reccomend not to mess too much with this diagram, it can get messy.
And here we conclude our brief introduction to SmartDiagram. You're welcome to keep reading this subsection of the Graphics section to find out how to draw with TikZ and PGFPlots.R
Author's note: I'd reccomend not to mess too much with this diagram, it can get messy.
And here we conclude our brief introduction to SmartDiagram. You're welcome to keep reading this subsection of the Graphics section to find out how to draw with TikZ and PGFPlots.R