2017-05-16 09:00:50 +00:00
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
|
2017-05-19 15:43:16 +00:00
|
|
|
import os
|
2017-05-16 09:00:50 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path += ['..']
|
|
|
|
|
|
|
|
from pyltk import subfloat, tabular, resizebox, makebox, figure
|
2017-05-19 15:43:16 +00:00
|
|
|
from pyltk.tikz import tikzpicture
|
|
|
|
from pyltk.pgfplots import axis, errorbars_plot, coordinates_plot
|
2017-05-16 09:00:50 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2017-05-19 15:43:16 +00:00
|
|
|
|
2017-05-16 09:00:50 +00:00
|
|
|
data = [[1.00000000e+00,
|
|
|
|
4.57213083e+00],
|
|
|
|
[2.00000000e+00,
|
2017-05-19 15:43:16 +00:00
|
|
|
1.16046200e+01],
|
|
|
|
[4.00000000e+00,
|
2017-05-16 09:00:50 +00:00
|
|
|
2.71873880e+01],
|
|
|
|
[ 5.00000000e+00,
|
|
|
|
3.36039380e+01],
|
|
|
|
[ 1.00000000e+01,
|
|
|
|
7.21689923e+01],
|
|
|
|
[ 2.00000000e+01,
|
|
|
|
1.50422028e+02]]
|
|
|
|
|
2017-05-19 15:43:16 +00:00
|
|
|
tk1 = tikzpicture()
|
|
|
|
tk1.add(axis(coordinates_plot('test', data),
|
|
|
|
xlabel='', ylabel='Computation Time [s]'))
|
2017-05-16 09:00:50 +00:00
|
|
|
|
|
|
|
tk2 = tikzpicture()
|
2017-05-19 15:43:16 +00:00
|
|
|
tk2.add(axis(errorbars_plot('test 2', [
|
2017-05-16 09:00:50 +00:00
|
|
|
[0, 5, (2, 3)],
|
|
|
|
[1, 8, (4, 5)]
|
2017-05-19 15:43:16 +00:00
|
|
|
])))
|
2017-05-16 09:00:50 +00:00
|
|
|
|
|
|
|
tk3 = tikzpicture()
|
2017-05-19 15:43:16 +00:00
|
|
|
tk3.add(axis(errorbars_plot('test 2', [
|
2017-05-16 09:00:50 +00:00
|
|
|
[0, 5, 3],
|
|
|
|
[4, 8, 4]
|
2017-05-19 15:43:16 +00:00
|
|
|
])))
|
|
|
|
|
|
|
|
tk4 = tikzpicture()
|
|
|
|
tk4.add(axis(coordinates_plot('test', [])))
|
|
|
|
|
|
|
|
s1 = subfloat('Caption 1', childrens=tk1)
|
|
|
|
s2 = subfloat('Caption 2', childrens=tk2)
|
|
|
|
s3 = subfloat('Caption 3', childrens=tk3)
|
|
|
|
s4 = subfloat('Caption 4', childrens=tk4)
|
|
|
|
|
|
|
|
tab = tabular(rows=[
|
|
|
|
[s1, s2],
|
|
|
|
[s3, s4]
|
|
|
|
], columns='cc', autowrap=resizebox)
|
|
|
|
|
|
|
|
f = figure(makebox(tab), '!h')
|
|
|
|
print(f) # f.childrens[0].childrens[0].childrens)
|
|
|
|
|
|
|
|
wrap = """\\documentclass{{article}}
|
|
|
|
\\usepackage{{amsmath,amsfonts,amssymb}}
|
|
|
|
\\usepackage{{tabularx}}
|
|
|
|
\\usepackage{{multirow}}
|
|
|
|
\\usepackage{{stmaryrd}}
|
|
|
|
\\usepackage{{hhline}}
|
|
|
|
\\usepackage{{caption}}
|
|
|
|
\\usepackage{{tikz}}
|
|
|
|
\\usetikzlibrary{{arrows}}
|
|
|
|
\\usetikzlibrary{{positioning}}
|
|
|
|
\\usepackage{{subfig}}
|
|
|
|
\\usepackage{{pgfplots}}
|
2017-05-16 09:00:50 +00:00
|
|
|
|
2017-05-19 15:43:16 +00:00
|
|
|
\\begin{{document}}
|
|
|
|
{content}
|
|
|
|
\\end{{document}}""".format(content=f)
|
2017-05-16 09:00:50 +00:00
|
|
|
|
2017-05-19 15:43:16 +00:00
|
|
|
with open('/tmp/test.tex', 'w') as fd:
|
|
|
|
fd.write(wrap)
|
2017-05-16 09:00:50 +00:00
|
|
|
|
2017-05-19 15:43:16 +00:00
|
|
|
os.system('pdflatex /tmp/test.tex')
|
|
|
|
os.system('evince test.pdf')
|