In [1]:
%load_ext ipylatex
In [2]:
import numpy as np
from pylatex import Document, TikZ, Axis, Plot
coordinates = np.random.rand(20,2)
In [3]:
%%pylatex --size 500,500
doc = Document(documentclass='standalone')
with doc.create(TikZ()):
plot_options = 'only marks, height=6cm, width=6cm, grid=major'
with doc.create(Axis(options=plot_options)) as plot:
plot.append(Plot(name='random', coordinates=coordinates))
generate_document(doc)
In [4]:
%%pylatex --size 500,500
doc = Document(documentclass='standalone')
with doc.create(TikZ()):
plot_options = 'height=6cm, width=6cm, grid=major'
with doc.create(Axis(options=plot_options)) as plot:
plot.append(Plot(name='model', func='-x^5 - 242'))
coordinates = [
(-4.77778, 2027.60977),
(-3.55556, 347.84069),
(-2.33333, 22.58953),
(-1.11111, -493.50066),
(0.11111, 46.66082),
(1.33333, -205.56286),
(2.55556, -341.40638),
(3.77778, -1169.24780),
(5.00000, -3269.56775),
]
plot.append(Plot(name='estimate', coordinates=coordinates))
generate_document(doc)
In [5]:
%%pylatex --size 350,350
doc = Document(documentclass='standalone')
with doc.create(TikZ()):
plot_options = 'ybar, height=6cm, width=6cm, grid=major'
with doc.create(Axis(options=plot_options)) as plot:
coordinates = [
(-4.77778, 2027.60977),
(-3.55556, 347.84069),
(-2.33333, 22.58953),
(-1.11111, -493.50066),
(0.11111, 46.66082),
(1.33333, -205.56286),
(2.55556, -341.40638),
(3.77778, -1169.24780),
(5.00000, -3269.56775),
]
plot.append(Plot(name='estimate', coordinates=coordinates))
generate_document(doc)