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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
proc FormatAxisLabel {graph x} {
return "[expr int($x)]\260"
}
set configOptions [subst {
Axis.Hide no
Axis.Limits "%g"
BorderWidth 1
Element.Pixels 1.75m
Element.ScaleSymbols no
Legend.ActiveBorderWidth 2
Legend.ActiveRelief raised
Legend.Anchor ne
Legend.BorderWidth 0
Legend.Position plotarea
Relief sunken
Title "Sine and Cosine Functions"
x.Command [namespace current]::FormatAxisLabel
x.StepSize 90
x.Subdivisions 0
x.Title "X"
y.Color purple2
y.Loose no
y.Title "Y"
y.rotate 90
y2.color magenta3
}]
set resName [string trimleft $graph .]
foreach { option value } $configOptions {
option add *$resName.$option $value
}
$graph configure -leftvar changed
set tcl_precision 15
set pi1_2 [expr 3.14159265358979323846/180.0]
foreach name { x sinX cosX } {
blt::vector create $name -variable ""
}
x seq -360 360 100
sinX expr { sin(x*$pi1_2) }
cosX expr { cos(x*$pi1_2) }
set img [image create picture -width 25 -height 25]
$img blank 0x00000000
$img draw circle 12 12 5 -shadow 0 -linewidth 0 \
-color 0x90FF0000 -antialias yes
$graph element create \
-label "sin(x)" \
-fill orange \
-color black \
-x x \
-y sinX \
-symbol @$img
set img [image create picture -width 25 -height 25]
$img blank 0x00000000
$img draw circle 12 12 5 -shadow 0 -linewidth 0 \
-color 0x900000F0 -antialias yes
$graph element create \
-label "cos(x)" \
-color yellow4 \
-fill yellow \
-x x \
-y cosX \
-symbol @$img
Blt_ZoomStack $graph
Blt_Crosshairs $graph
Blt_ActiveLegend $graph
Blt_ClosestPoint $graph
#Blt_PrintKey $graph
$graph marker create bitmap \
-name bg \
-coords "-360 -1 360 1" \
-bitmap @bitmaps/greenback.xbm \
-bg darkseagreen1 \
-fg darkseagreen3 \
-under yes \
-rotate 45
# -rotate 45
$graph postscript configure \
-landscape yes
|