Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow TikZ plots to append options #312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pylatex/tikz.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ def __init__(self,
func=None,
coordinates=None,
error_bar=None,
options=None):
options=None,
append_options=False):
"""
Args
----
Expand All @@ -517,13 +518,17 @@ def __init__(self,
A list of exact coordinates tat should be plotted.

options: str, list or `~.Options`
append_options: bool
If the given options should be appended to the automatically
assigned TikZ cycle list.
"""

self.name = name
self.func = func
self.coordinates = coordinates
self.error_bar = error_bar
self.options = options
self.append_options = append_options

super().__init__()

Expand All @@ -535,7 +540,14 @@ def dumps(self):
str
"""

string = Command('addplot', options=self.options).dumps()
if not isinstance(self.append_options, bool):
raise TypeError(
'argument "append_options" can only be of type bool')
elif not self.append_options:
command_string = 'addplot'
else:
command_string = 'addplot+'
string = Command(command_string, options=self.options).dumps()

if self.coordinates is not None:
string += ' coordinates {%\n'
Expand Down
2 changes: 1 addition & 1 deletion tests/test_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_tikz():
repr(a)

p = Plot(name=None, func=None, coordinates=None, error_bar=None,
options=None)
options=None, append_options=None)
repr(p)

opt = TikZOptions(None)
Expand Down