Skip to content

Commit

Permalink
Handle xlim/ylim.
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentMazare committed May 12, 2019
1 parent 2e34511 commit cd8172c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/matplotlib/fig_ax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ module Ax = struct
let set_title t title =
ignore (t.&("set_title")[| Py.String.of_string title |])

let set_xlim t ~left ~right =
ignore (t.&("set_xlim")[| Py.Float.of_float left; Py.Float.of_float right |])

let set_ylim t ~bottom ~top =
ignore (t.&("set_ylim")[| Py.Float.of_float bottom; Py.Float.of_float top |])

let set_xlabel t label =
ignore (t.&("set_xlabel")[| Py.String.of_string label |])

Expand Down
2 changes: 2 additions & 0 deletions src/matplotlib/fig_ax.mli
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Ax : sig
type t

val set_title : t -> string -> unit
val set_xlim : t -> left:float -> right:float -> unit
val set_ylim : t -> bottom:float -> top:float -> unit
val set_xlabel : t -> string -> unit
val set_ylabel : t -> string -> unit
val grid : t -> ?which:[`major|`minor|`both] -> ?axis:[`both|`x|`y] -> bool -> unit
Expand Down
16 changes: 12 additions & 4 deletions src/matplotlib/pyplot.ml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
open Base
open Pyops

let xlabel label =
let p = Mpl.pyplot_module () in
ignore (p.&("xlabel")[| Py.String.of_string label |])

let title label =
let p = Mpl.pyplot_module () in
ignore (p.&("title")[| Py.String.of_string label |])

let xlabel label =
let p = Mpl.pyplot_module () in
ignore (p.&("xlabel")[| Py.String.of_string label |])

let ylabel label =
let p = Mpl.pyplot_module () in
ignore (p.&("ylabel")[| Py.String.of_string label |])

let xlim ~left ~right =
let p = Mpl.pyplot_module () in
ignore (p.&("xlim")[| Py.Float.of_float left; Py.Float.of_float right |])

let ylim ~bottom ~top =
let p = Mpl.pyplot_module () in
ignore (p.&("ylim")[| Py.Float.of_float bottom; Py.Float.of_float top |])

let grid b =
let p = Mpl.pyplot_module () in
ignore (p.&("grid")[| Py.Bool.of_bool b |])
Expand Down
2 changes: 2 additions & 0 deletions src/matplotlib/pyplot.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
val xlim : left:float -> right:float -> unit
val ylim : bottom:float -> top:float -> unit
val xlabel : string -> unit
val ylabel : string -> unit
val grid : bool -> unit
Expand Down

0 comments on commit cd8172c

Please sign in to comment.