title | author | output | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
My Tikz Bars |
Alfonso R. Reyes |
|
- Output files like .png and .pdf are now being stored in
./out
- The
README.Rmd
document now allows to customize variables for the folders - The Hugo website through the
_build_site.R
script also allow some customization - The source folder with TikZ files are now only saved in
src
. Onlytex
files - The template file
template.Rmd
includes now special identifiers so it can be updated with user custom settings thatchild.Rmd
uses to retrieve all graphics and code for each of the examples - The
Makefile
has been optimized to avoid code repetition - All data files for the TikZ examples now live under
src/data
This is a repository of the best TikZ examples I have found around the web and from papers, slides, tutorials, and books. Most of the examples are simple enough to encourage anyone to start learning TikZ. By having the result (graphic) on a web page, and be able to click on it to see the code, it rapidly helps to make the connection between code and output. I find this idea fantastic.
TikZ is ideal for any kind of publications either websites, blogs, papers, articles, slides, or books because they are portable and reproducible. TikZ files are text not binaries. They don't require mouse and clicks but writing code to connect objects and elements. These object can be very simple or as sophisticated as you want. TikZ graphics can be built under any LaTex environment for any operating system: Windows, Linux or Mac OS.
There are hundreds of libraries for TikZ in all scientific fields. That makes it easier to build advanced graphics for practically any domain or discipline because you are able to start from code already written.
While working with Latex and TikZ file I had this question:
How can I use the power of R to organize TikZ related files?
R is very friendly to Latex and TikZ through the packages knitr
and rmarkdown
.
TikZ involves a source file, which carries the tex
extension; the PDF that is generated by your Latex compiler and editor (I use TexStudio); the graphics output file -that could be anything imaginable. I use png
files.
This README
is smartly generated with TikZ graphics and code located in the src
folder.
This means that as you are adding, building, designing new TikZ drawings, they become available to be automatically included in this README file. It uses some knitr
tricks. But the whole thing is awesome.
The magic is provided by:
- the file
template.Rmd
- the chunks of code that you can see in this
README
This is a very interesting article about publshing your TikZ site: Simple deployment to GH Pages. I chose to publish it in /docs
instead of the public
folder because it is much easier to deploy. GHP does not allow to publish a website on a folder named public
, unfortunately.
I found this valuable resource while exploring TikZ and R: https://github.com/walmes/Tikz
It is pretty neat and relatively simple to use and personalize because it uses Hugo, a generator of static websites; the same engine that is used by blogdown
, bookdown
, and others.
Thanks to Walmes Zeviani for the great idea of combining Latex, TikZ, R and Hugo.
Source: https://github.com/walmes/Tikz Web: http://leg.ufpr.br/~walmes/Tikz/
This is my collection of favorite TikZ graphics. It is necessary to store and organize them as gallery because it makes it easier to peek at the code for new designs.
Some useful tutorials:
- TikZ Adventskalender
- TikZ for the Impatient
- http://www.mat.ufpb.br/lenimar/introtikz.pdf
- LaTeX for Economists
- Configurable Graph Drawing Algorithmsfor the TikZ Graphics Description Language
- TikZ for Economics By Chiu Yu Ko
- http://www.statistiker-wg.de/pgf/tutorials.htm
- A very minimal introduction to TikZ
- TikZ Tutorial
- There are 4 total Tikz figures saved as
.tex
files in this gallery. The figures are sorted by filename. - There are 4 files under
src/
to be compiled withpdflatex
- There are 0 files under
src/
to be compiled withlualatex
- There are 0 data files under the folder
src/data
that are being used by the TikZ scripts - There are 0 Latex classes, styles and library files under the
src/texmf
folder
\documentclass{standalone}
%\documentclass{article}
% translate with >> pdflatex -shell-escape <file>
% This file is an extract of the PGFPLOTS manual, copyright by Christian Feuersaenger.
%
% Feel free to use it as long as you cite the pgfplots manual properly.
%
% See
% http://pgfplots.sourceforge.net/pgfplots.pdf
% for the complete manual.
%
% Any required input files (for <plot table> or <plot file> or the table package) can be downloaded
% at
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/
% and
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/plotdata/
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot+[xbar] coordinates
{(4,0) (1,1) (2,2)
(5,3) (6,4) (1,5)};
\end{axis}
\end{tikzpicture}
\end{document}
% https://www.latex4technics.com/?note=U130YI
% https://tex.stackexchange.com/a/370552/173708
\documentclass[a4paper, 12pt]{article}
\usepackage[paperwidth=5in, paperheight=3.2in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\geometry{left=0mm, right=3mm,top=6mm, bottom=3mm,}
\definecolor{mygr}{HTML}{e6e6e6}
\begin{document}
\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}[
/pgf/number format/1000 sep={},
width=3.8in,
height=1.8in,
at={(0.758in,0.981in)},
scale only axis,
clip=false,
separate axis lines,
axis on top,
xmin=0,
xmax=5,
xtick={1,2,3,4},
x tick style={draw=none},
xticklabels={GREEN,BLUE,GREY,RED},
ytick={0, 500, 1000, 2000},
ymin=0,
ymax=2000,
ylabel={YYY},
ymajorgrids,
every axis plot/.append style={
ybar,
bar width=.2,
bar shift=0pt,
fill
}
]
\addplot[green]coordinates {(1,600)};
\addplot[blue]coordinates{(2,1100)};
\addplot[mygr]coordinates{(3,1200)};
\addplot[red]coordinates{(4,1800)};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
% https://tex.stackexchange.com/a/157028/173708
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\begin{document}
\pgfplotstableread[row sep=\\,col sep=&]{
interval & carT & carD & carR \\
0--2 & 1.2 & 0.1 & 0.2 \\
2--5 & 12.8 & 3.8 & 4.9 \\
5--10 & 15.5 & 10.4 & 13.4 \\
10--20 & 14.0 & 17.3 & 22.2 \\
20--50 & 7.9 & 21.1 & 27.0 \\
50+ & 3.0 & 22.3 & 28.6 \\
}\mydata
\begin{tikzpicture}
\begin{axis}[
ybar,
bar width=.5cm,
width=\textwidth,
height=.5\textwidth,
legend style={at={(0.5,1)},
anchor=north,legend columns=-1},
symbolic x coords={0--2,2--5,5--10,10--20,20--50,50+},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
ymin=0,ymax=35,
ylabel={\%},
]
\addplot table[x=interval,y=carT]{\mydata};
\addplot table[x=interval,y=carD]{\mydata};
\addplot table[x=interval,y=carR]{\mydata};
\legend{Trips, Distance, Energy}
\end{axis}
\end{tikzpicture}
\end{document}
\documentclass{standalone}
% translate with >> pdflatex -shell-escape <file>
% This file is an extract of the PGFPLOTS manual, copyright by Christian Feuersaenger.
%
% Feel free to use it as long as you cite the pgfplots manual properly.
%
% See
% http://pgfplots.sourceforge.net/pgfplots.pdf
% for the complete manual.
%
% Any required input files (for <plot table> or <plot file> or the table package) can be downloaded
% at
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/
% and
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/plotdata/
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar, xmin=0,
width=12cm, height=3.5cm, enlarge y limits=0.5,
xlabel={\#participants},
symbolic y coords={no,yes},
ytick=data,
nodes near coords, nodes near coords align={horizontal},
]
\addplot coordinates {(3,no) (7,yes)};
\end{axis}
\end{tikzpicture}
\end{document}
I am implementing a very primitive tag system based of identifiers that are included in the filenames. I started to do this in TikZ because the graphics could belong to different categories at the same time. My plan is using what is available in the operating systems. Tools like grep
, find
, regex
, etc., should make this possible. I have done a pilot of this and seems to be working.
To tag the file -as you will see in the repository- I use the plus sign. I tried different symbols and this symbol is not obfuscated as a search string.
- Characters that pass the search test at OS level:
@
,!
,=
,+
. - Character that do not pass:
#
.
Other possibilities include using the comments section of the TikZ file to add the tags and categories.