Skip to content

Commit f13c9cf

Browse files
committed
Allow TikZ plots to append options
1 parent 71bac0b commit f13c9cf

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

pylatex/tikz.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ def __init__(self,
505505
func=None,
506506
coordinates=None,
507507
error_bar=None,
508-
options=None):
508+
options=None,
509+
append_options=False):
509510
"""
510511
Args
511512
----
@@ -517,13 +518,17 @@ def __init__(self,
517518
A list of exact coordinates tat should be plotted.
518519
519520
options: str, list or `~.Options`
521+
append_options: bool
522+
If the given options should be appended to the automatically
523+
assigned TikZ cycle list.
520524
"""
521525

522526
self.name = name
523527
self.func = func
524528
self.coordinates = coordinates
525529
self.error_bar = error_bar
526530
self.options = options
531+
self.append_options = append_options
527532

528533
super().__init__()
529534

@@ -535,7 +540,14 @@ def dumps(self):
535540
str
536541
"""
537542

538-
string = Command('addplot', options=self.options).dumps()
543+
if not isinstance(self.append_options, bool):
544+
raise TypeError(
545+
'argument "append_options" can only be of type bool')
546+
elif not self.append_options:
547+
command_string = 'addplot'
548+
else:
549+
command_string = 'addplot+'
550+
string = Command(command_string, options=self.options).dumps()
539551

540552
if self.coordinates is not None:
541553
string += ' coordinates {%\n'

tests/test_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def test_tikz():
204204
repr(a)
205205

206206
p = Plot(name=None, func=None, coordinates=None, error_bar=None,
207-
options=None)
207+
options=None, append_options=None)
208208
repr(p)
209209

210210
opt = TikZOptions(None)

0 commit comments

Comments
 (0)