Drawings
From time to time, you will certainly need to add text, arrows or markers at some points in you plot. Let’s consider the physical case of the discharge of a capacity C in a resistor R so that RC=2. Normally, it’s simply an exponential decay
ctioga -t 'RC circuit decay' -N --math --math-xrange 0:9 \
-x '$t$' -y '$U_C$' \
'exp(-x/2)' --yrange 0:1
Arrow
Cool.. But well, it’s a bit cheap, isn’t it ? Let’s add some graphical information. For example, after 3RC, the discharge is complete at 95% and so let’s draw an arrow to highlight this position
ctioga -t 'RC circuit decay' -N --math --math-xrange 0:9 \
-x '$t$' -y '$U_C$' \
'exp(-x/2)' --yrange 0:1 \
--draw "arrow: 6,0.2 6,0.07"
To do this, we used the --draw switch followed by the keyword “arrow” and the
indication of its origin (6,0.2) and target (6,0.07). The head and tail of the
arrow are usually too big, so we will use options in the form “option=value”
to get it right
ctioga -t 'RC circuit decay' -N --math --math-xrange 0:9 \
-x '$t$' -y '$U_C$' \
'exp(-x/2)' --yrange 0:1 \
--draw "arrow: 6,0.2 6,0.07 tail_scale=0.1 head_scale=0.5"
Other valid options are
- “tail_marker” and “head_marker” to change the default markers used. The given value should be a valid Tioga Marker ;
- “line_style” which value should be a valid Tioga Line_Type as given on page
http://theory.kitp.ucsb.edu/~paxton/tioga_doc/classes/Tioga/Strokes.html
- “line_width” which specify the width of the arrow line ;
- and finally “color” to change the color of the arrow.
Text
Well, we stil have to say why we draw this arrow. Let’s use the keyword “text” to do that for which you have to give the application point and the text to add
ctioga -t 'RC circuit decay' -N --math --math-xrange 0:9 \
-x '$t$' -y '$U_C$' \
'exp(-x/2)' --yrange 0:1 \
--draw "arrow: 6,0.2 6,0.07 tail_scale=0.1 head_scale=0.5" \
--draw "text: 6,0.22 '\$95\\%\$ decay'"
Note that due to multiple evaluation, you have to specify escape caracters for ”$” and ”\” so that LaTeX really see $95\%$.
Tangent
If you would like to add an arrow on a curve, the “tangent” keyword will do it. It is basically an arrow and so share the same options. But the position indication is the fraction of the data vector to place it. For example, if you have 200 data points, specifiing 0.35 will put the tangent where the 70th data point is located. This has to be done that way because a curve can go back and forth and only the position into the data structure can help to define uniquely where the tangent should apply. Here we will indicate the direction of decay in the middle of the graph
ctioga -t 'RC circuit decay' -N --math --math-xrange 0:9 \
-x '$t$' -y '$U_C$' \
'exp(-x/2)' --yrange 0:1 \
--draw "arrow: 6,0.2 6,0.07 tail_scale=0.1 head_scale=0.5" \
--draw "text: 6,0.22 '\$95\\%\$ decay'" \
--draw "tangent: 0.5 head_scale=0.7"
What is interesting to discover in our physical problem is the value of RC
which is given by the intersection of the tangent at the origin with the x
axis. We can then use the option xextent or yextent. But now, to be able to
compute properly the tangent at the origin, we have to extent the definition
domain of our exponential, for example from -1 to get a simple position of the
“0” value at 0.1=(0-(-1))/(9-(-1))
ctioga -t 'RC circuit decay' -N --math --math-xrange -1:9 \
-x '$t$' -y '$U_C$' \
'exp(-x/2)' --yrange 0:1 --xrange 0:9 \
--draw "arrow: 6,0.2 6,0.07 tail_scale=0.1 head_scale=0.5" \
--draw "text: 6,0.22 '\$95\\%\$ decay'" \
--draw "tangent: 0.5 head_scale=0.7" \
--draw "tangent: 0.1 head_scale=0.1 xextent=2 color=Black"
We could also have used the “yextent” option, but there we have to go towards the negative values
ctioga -t 'RC circuit decay' -N --math --math-xrange -1:9 \
-x '$t$' -y '$U_C$' \
'exp(-x/2)' --yrange 0:1 --xrange 0:9 \
--draw "arrow: 6,0.2 6,0.07 tail_scale=0.1 head_scale=0.5" \
--draw "text: 6,0.22 '\$95\\%\$ decay'" \
--draw "tangent: 0.5 head_scale=0.7" \
--draw "tangent: 0.1 head_scale=0.1 yextent=-1 color=Black"
Marker
Finally, let’s add some text on this tangent using the respective options
ctioga -t 'RC circuit decay' -N --math --math-xrange -1:9 \
-x '$t$' -y '$U_C$' \
'exp(-x/2)' --yrange 0:1 --xrange 0:9 \
--draw "arrow: 6,0.2 6,0.07 tail_scale=0.1 head_scale=0.5" \
--draw "text: 6,0.22 '\$95\\%\$ decay'" \
--draw "tangent: 0.5 head_scale=0.7" \
--draw "tangent: 0.1 head_scale=0.1 yextent=-1 color=Black" \
--draw "text: 1.9,0.15 '\$\\tau=RC\$' \
angle=-77 scale=2 color=Blue"
and a funny marker using the “marker” keyword
ctioga -t 'RC circuit decay' -N --math --math-xrange -1:9 \
-x '$t$' -y '$U_C$' \
'exp(-x/2)' --yrange 0:1 --xrange 0:9 \
--draw "arrow: 6,0.2 6,0.07 tail_scale=0.1 head_scale=0.5" \
--draw "text: 6,0.22 '\$95\\%\$ decay'" \
--draw "tangent: 0.5 head_scale=0.7" \
--draw "tangent: 0.1 head_scale=0.1 yextent=-1 color=Black" \
--draw "text: 1.9,0.15 '\$\\tau=RC\$' \
angle=-77 scale=2 color=Blue" \
--draw "marker: 1.5,0.05 OtherHand \
angle=-45 scale=2 color=Blue"
A reminder of all the options and drawing abilities can be found using the
--draw-help option on the command line.