@@ -305,7 +305,7 @@ def get_draw_options(data, obj, ec, fc, ls, lw, hatch=None):
305305 draw_options .append (lw_ )
306306
307307 if ls is not None :
308- ls_ = mpl_linestyle2pgfplots_linestyle (ls )
308+ ls_ = mpl_linestyle2pgfplots_linestyle (data , ls )
309309 if ls_ is not None and ls_ != "solid" :
310310 draw_options .append (ls_ )
311311
@@ -352,7 +352,8 @@ def mpl_linewidth2pgfp_linewidth(data, line_width):
352352 }[line_width ]
353353 except KeyError :
354354 # explicit line width
355- return f"line width={ line_width } pt"
355+ ff = data ["float format" ]
356+ return f"line width={ ff } pt" .format (line_width )
356357
357358 # The following is an alternative approach to line widths.
358359 # The default line width in matplotlib is 1.0pt, in PGFPlots 0.4pt
@@ -371,12 +372,13 @@ def mpl_linewidth2pgfp_linewidth(data, line_width):
371372 }[scaled_line_width ]
372373 except KeyError :
373374 # explicit line width
374- out = "line width={}pt" .format (0.4 * line_width )
375+ ff = data ["float format" ]
376+ out = f"line width={ ff } pt" .format (0.4 * line_width )
375377
376378 return out
377379
378380
379- def mpl_linestyle2pgfplots_linestyle (line_style , line = None ):
381+ def mpl_linestyle2pgfplots_linestyle (data , line_style , line = None ):
380382 """Translates a line style of matplotlib to the corresponding style
381383 in PGFPlots.
382384 """
@@ -388,15 +390,19 @@ def mpl_linestyle2pgfplots_linestyle(line_style, line=None):
388390 # dashed: (0, (6.0, 6.0))
389391 # dotted: (0, (1.0, 3.0))
390392 # dashdot: (0, (3.0, 5.0, 1.0, 5.0))
393+ ff = data ["float format" ]
391394 if isinstance (line_style , tuple ):
392395 if line_style [0 ] is None :
393396 return None
394397
395398 if len (line_style [1 ]) == 2 :
396- return "dash pattern=on {}pt off {}pt" .format (* line_style [1 ])
399+ fmt = f"dash pattern=on { ff } pt off { ff } pt"
400+ print (fmt , type (fmt ))
401+ return fmt .format (* line_style [1 ])
397402
398403 assert len (line_style [1 ]) == 4
399- return "dash pattern=on {}pt off {}pt on {}pt off {}pt" .format (* line_style [1 ])
404+ fmt = f"dash pattern=on { ff } pt off { ff } pt on { ff } pt off { ff } pt"
405+ return fmt .format (* line_style [1 ])
400406
401407 if isinstance (line , mpl .lines .Line2D ) and line .is_dashed ():
402408 # see matplotlib.lines.Line2D.set_dashes
@@ -411,7 +417,7 @@ def mpl_linestyle2pgfplots_linestyle(line_style, line=None):
411417 lst = list ()
412418 if dashSeq != default_dashSeq :
413419 # generate own dash sequence
414- format_string = " " .join (len (dashSeq ) // 2 * ["on {}pt off {}pt" ])
420+ format_string = " " .join (len (dashSeq ) // 2 * [f "on { ff } pt off { ff } pt" ])
415421 lst .append ("dash pattern=" + format_string .format (* dashSeq ))
416422
417423 if dashOffset != default_dashOffset :
0 commit comments