JelteF / PyLaTeX

A Python library for creating LaTeX files
https://jeltef.github.io/PyLaTeX/
MIT License
2.24k stars 287 forks source link

xtick for pgfplots #342

Open OliverFaust opened 2 years ago

OliverFaust commented 2 years ago

Dear experts,

Including 'xtick={-1, 0, 1}' in the plot options for Axis creates xtick={{-}1, 0, 1} in the latex code. How do I generate the correct latex code: xtick={-1, 0, 1}?

Minimum example to reproduce the error:

from pylatex import Document, Axis, Plot, TikZ
import os
if __name__ == '__main__':
    image_filename = os.path.join(os.path.dirname(__file__), 'kitten.jpg')
    geometry_options = {"tmargin": "1cm", "lmargin": "10cm"}
    doc = Document(geometry_options=geometry_options)
    plot_options = 'height=4cm, width=6cm, grid=major, xtick={-1, 0, 1}'
    with doc.create(TikZ()):
        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))
    doc.generate_pdf('full', clean_tex=False)