Skip to main content

Python lib for generating TikZ charts from table data

Project description

What is ZikT?

ZikT creates charts like pie charts and bar charts for LaTeX documents. Therefore, ZikT turns table data into TikZ code, that can be embedded or inputted in any LaTeX document. TikZ (and the underlying PGF) is a macro package for TeX. You can find beautiful examples for graphics created with TikZ on texample.net.

ZikT can be used as Python library to create TikZ code for charts from you own Python stuff. ZikT can also be used as script that reads in CSV data, takes a chart specification and prints out the resulting TikZ code to stdout. A sample usage of this script on Linux is

zikt -l mydata.csv -r "BarChart(additionalBarStyle='fill=red')" > mychart.tex

Currently, ZikT supports these chart types:

  • bar charts

  • grouped bar charts

  • stacked bar charts

  • pie charts

  • plot charts

ZikT is in an early and experimental state and lacks a lot of important features like the creation of a chart legend. Working features are for example a flexible way to specify labels and automated axis labeling.

Further Information

Do I need to know LaTeX to use ZikT?

Well, some very basic knowledge to embed the TikZ code and to compile the document is needed. But―of cause―you will need to know LaTeX if you want to write documents around your charts. :)

Do I need to know TikZ/PGF to use ZikT?

No. But if you do, you will have more options to style your charts and you will be able to manipulate and extend ZikTs output manually.

Can I use ZikT without programming Python?

I have written a simple command line front end for ZikT. It enables you to read in a CSV file and to print out the charts TikZ code to stdout. This front end script is zikt.py which can be found within the zikt package.

Is there any further documentation?

I’m working on a LaTeX based documentation but it is in an even earlier state than ZikT itself (surprise!). It is currently not available with the package. If you are intrested in this, let me know and maybe I will hurry up a little with the documentation.

Short example for programmatic usage?

Okay.

from zikt.tables import FloatTable
from zikt.barchart import BarChart

data = [
        ['A','B','C'],
        [2,12,-3]
        ]

table = FloatTable(data)

chart = BarChart()

chartCode = chart.render(table)

print "\\begin{tikzpicture}"
print chartCode
print "\\end{tikzpicture}"

Pipe the output of this program into a file in a an empty directory. On Linux it may

./upper_script.py > diagram.tex

The TikZ output of ZikT depends on several color and TikZ definitions that are located in zikt.sty, delivered with the package in the latex sub package. As a convenience function, the zikt script can print it to stdout. So, the easiest option is to use a zikt.sty copy for each LaTeX document containing ZikT charts. Create that zikt.sty in your working directory. On Linux it may look like this:

zikt --printsty > zikt.sty

Last but not least you need the surrounding document. Create mydoc.tex with something like following content:

\documentclass{scrartcl}
\usepackage{zikt}
\begin{document}
 \input{diagram}
\end{document}

Compile that file with a compatible LaTeX compiler. I would use lualatex -interaction=nonstopmode mydoc.tex. You should have a very senseless mydoc.pdf then where you can see a very basic ZikT bar chart.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ZikT-0.1.3.tar.gz (29.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page