1919 script* : seq [string ]
2020 latex* : bool
2121 plots* : seq [Plot ]
22+ font* : tuple [family: string , style: string ]
2223
2324proc save * (figure: Figure , dest: string ) =
2425 var script = newSeq [string ]()
@@ -27,7 +28,8 @@ proc save*(figure: Figure, dest: string) =
2728 script.add " from matplotlib import rc"
2829 script.add " import matplotlib.pyplot as plt"
2930 script.add " from matplotlib.lines import Line2D"
30- # script.add "rc('font', **{'family': '#{@font.family}', 'serif': '#{@font.styles.to_s}'})"
31+ if figure.font.family!= " " :
32+ script.add " rc('font', **{'family': '" & figure.font.family & " ', 'serif': '" & figure.font.style & " '})"
3133 let latex_str = if figure.latex: " True" else : " False"
3234 script.add fmt" rc('text', usetex={ latex_str} ) "
3335 script.add " matplotlib.rcParams['text.latex.unicode']=True"
@@ -44,7 +46,10 @@ proc save*(figure: Figure, dest: string) =
4446
4547
4648proc newFigure * (): Figure =
47- Figure (python: " /usr/local/bin/python3" , script: newSeq [string ](), latex: false )
49+ Figure (python: " /usr/local/bin/python3" ,
50+ script: newSeq [string ](),
51+ latex: false ,
52+ font: (" " , " " ))
4853
4954proc add * (figure: Figure , plot: Plot ) =
5055 figure.plots.add plot
@@ -132,4 +137,11 @@ method render[A,B](this: Line[A,B]): string =
132137 return fmt" ax = plt.gca(){ '\n ' } ax.add_line(Line2D([{ this.p0.x} ,{ this.p1.x} ],[{ this.p0.y} ,{ this.p1.y} ])) "
133138
134139proc newLine * [A,B](ps: tuple [x: A, y: B], pe: tuple [x: A, y: B]): Line [A, B] =
135- Line [A,B](p0: ps, p1: pe, linestyle: " " , colour: " " )
140+ Line [A,B](p0: ps, p1: pe, linestyle: " " , colour: " " )
141+
142+ # Title
143+ type Title = ref object of Plot
144+ title* : string
145+ method render (this: Title ): string = fmt" plt.title(r'{ this.title} ') "
146+
147+ proc newTitle * (title: string ): Title = Title (title: title)
0 commit comments