eigenhombre / i3d3

D3-based plotting and histogramming library
25 stars 5 forks source link

Plot title #3

Closed mrocklin closed 10 years ago

mrocklin commented 10 years ago

I may be missing something but I can't easily find out how to add a title to a graph. Is this feature supported? If now how quickly could it be done? I need this relatively soon and so am willing to do it myself if given guidance.

eigenhombre commented 10 years ago

You can simply add text to the plot, using e.g.,

i3d3.plot({data: [...], ..., extras: [{note: {x: 6, y: 200, text: “My Awesome Title", style: "font-size: 20; font-style: italic;"}}]

Do you have requirements that this doesn’t meet?

On Oct 29, 2013, at 11:23 AM, Matthew Rocklin notifications@github.com wrote:

I may be missing something but I can't easily find out how to add a title to a graph. Is this feature supported? If now how quickly could it be done? I need this relatively soon and so am willing to do it myself if given guidance.

— Reply to this email directly or view it on GitHub.

mrocklin commented 10 years ago

Ah, I didn't know that was possible.

Is there an absolute scale I can use other than x and y? I'd like to specify the position in screen coordinates rather than data coordinates. I often redraw my plots with newly accumulated data which changes the scales. This text starts moving around rather than staying fixed.

eigenhombre commented 10 years ago

x and y are either screen or data coordinates:

if(v.note.units === "pixels") { X = v.note.x; Y = v.note.y; } else { X = xscale(v.note.x); Y = yscale(v.note.y); }

On Oct 29, 2013, at 11:48 AM, Matthew Rocklin notifications@github.com wrote:

Ah, I didn't know that was possible.

Is there an absolute scale I can use other than x and y? I'd like to specify the position in screen coordinates rather than data coordinates. I often redraw my plots with newly accumulated data which changes the scales. This text starts moving around rather than staying fixed.

— Reply to this email directly or view it on GitHub.

eigenhombre commented 10 years ago

@mrocklin Can you advise if this issue is resolved for you?

mrocklin commented 10 years ago

My immediate issue is resolved. Having a title keyword much like how you have xlabel and ylabel might be a welcome feature though.

eigenhombre commented 10 years ago

I’ll open an internal IceCube issue to do that, and close this one.

On Oct 30, 2013, at 2:10 PM, Matthew Rocklin notifications@github.com wrote:

My immediate issue is resolved. Having a title keyword much like how you have xlabel and ylabel might be a welcome feature though.

— Reply to this email directly or view it on GitHub.

eigenhombre commented 10 years ago

@mrocklin "Title" option has been added w/ latest commit:

[master 006f7a8] Issue 6744: (i3d3) Add title keyword/operation to add titles to top of plots 4 files changed, 18 insertions(+), 2 deletions(-) rewrite example.png (98%)

The last plot in the example HTML exercises this option.

mrocklin commented 10 years ago

Wonderful!