Page 1 of 1

.label(x, y, "label") in axes coordinates

Posted: Sun Jun 07, 2009 4:45 pm
by pfortier
To plot the voltage vectors of an n*m sheet of cells, I set gobj.size() to accommodate n*m vectors, offset the (x,y) values of each vector accordingly, and then use vector.line() to plot the data.

I wanted to label my traces. I found graph.label(x, y, "label") but this uses window coordinates so when you zoom or move around it is inappropriate.

Is there a graph.label(x, y, "label") that would draw text based on axes coordinates? This would allow me to label my traces and their position relative to the data would remain with zooming. If there isn't such a command, (1) is there another method or (2) would it be simple for someone with medium programming knowledge to code this feature based on the source code for graph.label(x, y, "label") and vector.line()?

Thanks,
Pierre

Re: .label(x, y, "label") in axes coordinates

Posted: Sun Jun 07, 2009 9:31 pm
by hines
http://www.neuron.yale.edu/neuron/stati ... html#label
gives the many arg form:
.label(x, y, "string", fixtype, scale, x_align, y_align, color)
you want fixtype=2 or fixtype=1 depending on your purpose.

Re: .label(x, y, "label") in axes coordinates

Posted: Wed May 26, 2010 10:39 am
by pfortier
To place a label aligned on axis coordinates, the following code seems to work well.

// labelcoordinate=lblxy(xORyCase,graph,axiscoordinate): converts axis to label coordinate

Code: Select all

func lblxy() { return $o2.view_info(0, $1, $3)+$3 }
objref g
g = new Graph()
g.size(0,100,0,100)
g.label(lblxy(11, g, 20), lblxy(12, g, 60), "MyLabel", 1, 1, 0.1, 0.1, 3)
Thanks,
Pierre