diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 10f1c6d7..9084e0e3 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -14,6 +14,14 @@ This version might not be stable, but to install it use:: pip install git+https://github.com/JelteF/PyLaTeX.git +1.3.1_ - `docs <../v1.3.1/>`__ - 2019-04-28 +------------------------------------------- + +Added +~~~~~ +- TikZ's Plot now has ``trailing_path`` parameter for appending a trailing path command to the final drawing command. + + 1.3.0_ - `docs <../v1.3.0/>`__ - 2017-05-19 ------------------------------------------- diff --git a/pylatex/tikz.py b/pylatex/tikz.py index 3f40e4dc..a973b0df 100644 --- a/pylatex/tikz.py +++ b/pylatex/tikz.py @@ -8,6 +8,7 @@ from .base_classes import LatexObject, Environment, Command, Options, Container from .package import Package +from .utils import _latex_item_to_string import re import math @@ -504,6 +505,7 @@ def __init__(self, name=None, func=None, coordinates=None, + trailing_path=None, error_bar=None, options=None): """ @@ -514,14 +516,16 @@ def __init__(self, func: str A function that should be plotted. coordinates: list - A list of exact coordinates tat should be plotted. - + A list of exact coordinates that should be plotted. + trailing_path: str or `~.LatexObject` + A TikZ's trailing path command that should be appended to the final drawing command options: str, list or `~.Options` """ self.name = name self.func = func self.coordinates = coordinates + self.trailing_path = trailing_path self.error_bar = error_bar self.options = options @@ -552,10 +556,20 @@ def dumps(self): string += '(' + str(x) + ',' + str(y) + \ ') +- (' + str(e_x) + ',' + str(e_y) + ')%\n' - string += '};%\n%\n' + string += '}' + + if self.trailing_path is not None: + string += _latex_item_to_string(self.trailing_path) + + string += ';%\n%\n' elif self.func is not None: - string += '{' + self.func + '};%\n%\n' + string += '{' + self.func + '}' + + if self.trailing_path is not None: + string += _latex_item_to_string(self.trailing_path) + + string += ';%\n%\n' if self.name is not None: string += Command('addlegendentry', self.name).dumps() diff --git a/tests/test_args.py b/tests/test_args.py index 5d9696d1..55112a84 100755 --- a/tests/test_args.py +++ b/tests/test_args.py @@ -203,7 +203,7 @@ def test_tikz(): a = Axis(data=None, options=None) repr(a) - p = Plot(name=None, func=None, coordinates=None, error_bar=None, + p = Plot(name=None, func=None, coordinates=None, trailing_path=None, error_bar=None, options=None) repr(p)