File: plotdemos17.tcl

package info (click to toggle)
tklib 0.6-1%2Bdeb8u1
  • links: PTS
  • area: main
  • in suites: jessie
  • size: 16,112 kB
  • ctags: 4,008
  • sloc: tcl: 65,204; sh: 6,870; ansic: 792; pascal: 359; makefile: 73; exp: 21; sed: 16
file content (42 lines) | stat: -rwxr-xr-x 1,007 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# plotdemos17.tcl --
#     Demonstrate how to configure the axes
#
#
source ../../plotchart.tcl
package require Plotchart


#
# Set up three plots
#
pack [canvas .c1 -bg white -width 400 -height 300]
pack [canvas .c2 -bg white -width 400 -height 300]
pack [canvas .c3 -bg white -width 400 -height 200]

set p1 [::Plotchart::createXYPlot .c1 {0 10 2} {-1 1 0.25}]
$p1 ytext "(V)"
$p1 xconfig -ticklength 20 -format %.3f
$p1 yconfig -ticklength 20 -minorticks 4 -labeloffset 10

set p2 [::Plotchart::createXYPlot .c2 {0 10 2} {-10 10 5}]
$p2 ytext "(mA)"

$p2 dataconfig current -colour red
$p2 xconfig -ticklength -6 -minorticks 1

#
# Fill in some data
#
for {set i 0} {$i < 100} {incr i} {
    set phase [expr {2.0*3.1415926*$i/50.0}]

    $p1 plot voltage $phase [expr {0.9*cos($phase)}]
    $p2 plot current $phase [expr {7*sin($phase)}]
}


#
# The third plot uses -xlabes and -ylabels to control
# the labelling
#
set p3 [::Plotchart::createXYPlot .c3 {0 10} {-10 10} -xlabels {1 4 6} -ylabels {-5 0}]