Adding a length scale bar to a Shape plot

Anything that doesn't fit elsewhere.
Post Reply
neuromau
Posts: 97
Joined: Mon Apr 20, 2009 7:02 pm

Adding a length scale bar to a Shape plot

Post by neuromau »

I would like to add a length scale bar to a shape plot, and a label ("100 um"):

Code: Select all

create soma, dend
connect dend(0), soma(1)

objref ss
ss = new Shape()
ss.label(0.1,.1,"100 um")
I thought perhaps I should use ss.beginline(x1,0.1) and ss.line(x2,0.1), but that didn't work for me (plus unsure of the unit conversion if it did work). How do I add the length scale to the shape plot?
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Adding a length scale bar to a Shape plot

Post by ted »

Allow me to present anatscale.hoc (part of the extracellular_stim_and_rec.zip package):

Code: Select all

// set up xyz scale bars
create xScale, yScale, zScale
proc anatscale() {
        if ($4>0) {  // if length arg is <= 0 then do nothing
                xScale {
                        pt3dclear()
                        pt3dadd($1, $2, $3, 1)
                        pt3dadd($1+$4, $2, $3, 1)
                }
                yScale {
                        pt3dclear()
                        pt3dadd($1, $2, $3, 1)
                        pt3dadd($1, $2+$4, $3, 1)
                }
                zScale {
                        pt3dclear()
                        pt3dadd($1, $2, $3, 1)
                        pt3dadd($1, $2, $3+$4, 1)
                }
        }
}
anatscale(100,0,0,100)  // xyz coords of origin, and length
neuromau
Posts: 97
Joined: Mon Apr 20, 2009 7:02 pm

Re: Adding a length scale bar to a Shape plot

Post by neuromau »

Awesome, thank you!
Post Reply