@@ -144,4 +144,44 @@ type Title = ref object of Plot
144144 title* : string
145145method render (this: Title ): string = fmt" plt.title(r'{ this.title} ') "
146146
147- proc newTitle * (title: string ): Title = Title (title: title)
147+ proc newTitle * (title: string ): Title = Title (title: title)
148+
149+ # Horizontal line
150+ type HorizontalLine [A] = ref object of Plot
151+ y* : A
152+ linestyle* : string
153+ colour* : string
154+ method render [A](this: HorizontalLine [A]): string =
155+ var options: seq [string ] = @ []
156+ if this.linestyle!= " " :
157+ options.add fmt" linestyle='{ this.linestyle} ' "
158+ if this.colour!= " " :
159+ options.add fmt" color='{ this.colour} ' "
160+ if len (options)> 0 :
161+ let optstr = options.join (" ," )
162+ return fmt" plt.axhline(y={ this.y} , { optstr} ) "
163+ else :
164+ return fmt" plt.axhline(y={ this.y} ) "
165+
166+ proc newHorizontalLine * [A](y: A): HorizontalLine [A] =
167+ HorizontalLine [A](y: y, linestyle: " " , colour: " " )
168+
169+ # Vertical line
170+ type VerticalLine [A] = ref object of Plot
171+ x* : A
172+ linestyle* : string
173+ colour* : string
174+ method render [A](this: VerticalLine [A]): string =
175+ var options: seq [string ] = @ []
176+ if this.linestyle!= " " :
177+ options.add fmt" linestyle='{ this.linestyle} ' "
178+ if this.colour!= " " :
179+ options.add fmt" color='{ this.colour} ' "
180+ if len (options)> 0 :
181+ let optstr = options.join (" ," )
182+ return fmt" plt.axvline(x={ this.x} , { optstr} ) "
183+ else :
184+ return fmt" plt.axvline(x={ this.x} ) "
185+
186+ proc newVerticalLine * [A](x: A): VerticalLine [A] =
187+ VerticalLine [A](x: x, linestyle: " " , colour: " " )
0 commit comments