nschloe / tikzplotlib

:bar_chart: Save matplotlib figures as TikZ/PGFplots for smooth integration into LaTeX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing support for 'markevery' options in Line2D

Blubbaa opened this issue · comments

Some options for markers in line plots are currently not supported, but would be nice to have.

According to the matplotlib docs, markevery can be an integer, tuple, slice, etc. but as far as i can see only the integer and explicit markers list is handled:

mark_every = obj.get_markevery()
if mark_every:
if type(mark_every) is int:
addplot_options.append(f"mark repeat={mark_every:d}")
else:
# python starts at index 0, pgfplots at index 1
pgf_marker = [1 + m for m in mark_every]
addplot_options.append(
"mark indices = {" + ", ".join(map(str, pgf_marker)) + "}"
)

Using a tuple with (start, spacing) will simply be misinterpreted as explicit indices, using slices will even create an error.

For the tuple usecase, an easy solution could be:

elif isinstance(mark_every, tuple):
    addplot_options.append(f"mark repeat={mark_every[1]:d}")
    addplot_options.append(f"mark phase={mark_every[0]+1:d}")