Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd05f0a

Browse files
author
Peter Würtz
committed
Merge pull request matplotlib#1251 from jenshnielsen/pgf_dashes
backend_pgf: custom dashstyles and compliance with other backends
2 parents 1485757 + 486d198 commit dd05f0a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/matplotlib/backends/backend_pgf.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -497,18 +497,16 @@ def _print_pgf_path_styles(self, gc, rgbFace):
497497
writeln(self.fh, r"\pgfsetstrokeopacity{%f}" % gc.get_alpha())
498498

499499
# line style
500+
dash_offset, dash_list = gc.get_dashes()
500501
ls = gc.get_linestyle(None)
501502
if ls == "solid":
502503
writeln(self.fh, r"\pgfsetdash{}{0pt}")
503-
elif ls == "dashed":
504-
dashargs = (2.5 * lw, 2.5 * lw)
505-
writeln(self.fh, r"\pgfsetdash{{%fpt}{%fpt}}{0pt}" % dashargs)
506-
elif ls == "dashdot":
507-
dashargs = (3 * lw, 3 * lw, 1 * lw, 3 * lw)
508-
writeln(self.fh, r"\pgfsetdash{{%fpt}{%fpt}{%fpt}{%fpt}}{0pt}" % dashargs)
509-
elif "dotted":
510-
dashargs = (lw, 3 * lw)
511-
writeln(self.fh, r"\pgfsetdash{{%fpt}{%fpt}}{0pt}" % dashargs)
504+
elif (ls == "dashed" or ls == "dashdot" or ls == "dotted"):
505+
dash_str = r"\pgfsetdash{"
506+
for dash in dash_list:
507+
dash_str += r"{%fpt}" % dash
508+
dash_str += r"}{%fpt}" % dash_offset
509+
writeln(self.fh, dash_str)
512510

513511
def _print_pgf_path(self, path, transform):
514512
f = 1. / self.dpi

0 commit comments

Comments
 (0)