OCaml Forge
SCM

Detail: [#1081] Request Array.xy ~base parameter

Feature Requests: Browse | Download .csv | Monitor

[#1081] Request Array.xy ~base parameter

Date:
2012-01-15 16:13
Priority:
3
State:
Open
Submitted by:
Edgar Friendly (thelema)
Assigned to:
Nobody (None)
Component:
None
Operating System:
All
Product:
None
 
Summary:
Request Array.xy ~base parameter

Detailed description
I have xy data that I wish to plot with a band shadow around it. I can plot three lines, with color highlighting the main line, but I'd like to turn the bracketing lines into a shadow.

Example of what I have: http://tinypic.com/r/20qbepj/5

Example of what I want: http://had.co.nz/ggplot2/graphics/8953194646b79f7e28d5bebd58b18616.png

Followup

Message
Date: 2012-01-15 18:25
Sender: Edgar Friendly

clever workaround - I'll apply it to my code and see how nice the results are.
Date: 2012-01-15 18:04
Sender: Pierre Hauweele

This will come with a refactoring of the plot functions, certainly with a different signature. But don't expect it to come in only a few days though.

So, in the meanwhile, you can get what you want using Array.xy ~fill:true with some crafted bracket data :

(* [rev_arr a] gives a reversed copy of array a. *)
let rev_arr a =
let l = Array.length a in
Array.init l (fun i -> a.(l - i - 1))

[...]

let vp = A.init [] in
(* your data *)
let x = [| 1.; 2.; 3.; 7.; 15. |]
and y = [| 3.; 2.; 7.; 2.; 1. |] in
(* your upper bracket data*)
let yu = Array.map ((+.) 1.) y
(* your down bracket data*)
and yd = Array.map ((+.) (-1.)) y in
(* we craft the data for the bracket plot *)
let bracketx = Array.append x (rev_arr x)
and brackety = Array.append yu (rev_arr yd) in
A.Axes.box vp;
(* get some nice filling color *)
let c = A.Color.rgba 0. 0. 0. 0.25 in
V.set_color vp c;
(* The fill argument of xy fills the inner path of the data. We constructed our bracket data such that its inner path is what we want to fill. *)
A.Array.xy vp bracketx brackety ~style:`Lines ~fill:true ~fillcolor:c;
V.set_color vp A.Color.blue;
A.Array.xy vp x y ~style:`Lines;
A.close vp

Attached Files:

Changes:

No Changes Have Been Made to This Item