''[JMeh] 03 Aug 2017'' - pdf4tcl::graph BLT/RBC commands for the [pdf4tcl] library - Rev. 1.0 from 02. Aug 2017 This is an output engine for "graph.tcl" to implement [BLT] (or [RBC]) commands of the graph object for generating PDF output using the "pdf4tcl" Package. It has no vector support (yet). Graph is a pure tcl library executing [BLT] (mostly compatible) graph command for output other than the screen. It needs a driver to produce for example PDF output. Therefore you can use the package pdf4tcl::graph. It uses the pdf4tcl library to generate the output. The graph library itself only calls procedures like "Line", "Rect", "Arc", "Text" and "Pict". They have to do the real drawing job. Drivers exists for generating PostScript, PDF with [pdf4tcl] and also for the commercial Debenu PDF Library. For all possible graph options have a look at the original [BLT] documentation. You can download the libraries "graph" and "pdf4tcl::graph" from here:<
> http://sesam-gmbh.org/images/Downloads/Public/pdf4tcl_graph.zip Noice: So far, "pdf4tcl" must be patched to support functions such as non-closed polygons and clipping. You can download a patched version from here (I hope the author of "pdf4tcl" incorporates this patch into his sources):<
> http://sesam-gmbh.org/images/Downloads/Public/pdf4tcl091p1.tar.bz2 Here is an example showing the usage of this libs: ======tcl package require pdf4tcl::graph pdf4tcl::new mypdf -paper a4 -unit mm mypdf startPage mypdf setFont 4 Helvetica mypdf text "Hello World" -x 10 -y 10 graph::setup pdf4tcl mypdf set mydata {21 17 5 9 25.4} set g [graph::graph -title "Example"] $g axis create y3 -color blue $g element create line1 -label "Data" -ydata mydata -fill red $g grid configure -hide no $g axis configure x -min 0 -max 100 $g axis configure y -loose no -hide no -max 25 -title Alpha $g draw 15 15 $g destroy mypdf write -file graph.pdf mypdf destroy ====== And this is the output: [pdf4tcl_graph_example0.png%|% width= 622 height= 374] Included in the download file are two other examples: ======tcl package require pdf4tcl::graph pdf4tcl::new mypdf -paper a4 -unit mm mypdf startPage mypdf setFont 12 Courier graph::setup pdf4tcl mypdf set data1 {0 1.1 0.25 1.5 0.5 1.3 0.75 1.9 1 2.2} set data2 {0 2.1 0.25 1.7 0.5 0.7 0.75 0.9 1 1.8} set g [graph::graph -title Kurven] $g element create line1 -label "Data 1" -data data1 -fill green -dashes ".," $g element create line2 -label "Data 2" -data data2 -symbol square -fill red -smooth natural $g legend configure -position @5,-3 $g grid configure -hide no -minor off -dashes . $g axis configure x -rotate 45 -minorticks {0.25 0.5 0.75} $g axis configure y -loose no -majorticks {0.5 1.0 1.1 1.2 1.3 1.4 1.5 2.0 2.5} $g axis configure y2 -min 0 -max 1 $g marker create line -coords {0 1.25 1 1.25} -dashes "-" $g marker create text -coords {0.5 1.25} -anchor n -text "Lower Limit\ny = 1.25" $g marker create line -mapy y2 -coords {0.8 0 0.8 1} -dashes "-" $g marker create text -mapy y2 -coords {0.8 0.25} -anchor w -text "Max." -rotate 90 $g axis configure x -title "X-Axis" $g axis configure y -title "Y-Axis" $g legend configure -hide no -position plotarea -anchor nw $g draw 15 15 $g destroy set histidx {1 2 3 4 5 6 7 8 9 10 } set histval {0.5 3.3 12.3 28.2 39.6 34.2 18.2 5.9 1.2 0.1} set g [graph::graph -title Histogramm] $g element create hist1 -label "Distribution" -xdata $histidx -ydata $histval -type bar -fill blue $g grid configure -hide no -minor off -mapx {} $g draw 15 115 $g destroy mypdf write -file graph1.pdf mypdf destroy ====== [pdf4tcl_graph_example1.png%|% width= 623 height= 956] ======tcl package require pdf4tcl::graph pdf4tcl::new mypdf -paper a4 -unit mm mypdf startPage graph::setup pdf4tcl mypdf set data(1) {21 17 5 9 25.4} set data(2) {0.8 2.1 1.2 2.2 0.2} set data(3) {85 96 73 99 88} proc DrawGraph {} { set g [graph::graph -width 180] $g axis create y3 -color blue $g y2axis use {y3 y2} foreach {idx color axis} {1 green y 2 red y2 3 blue y3} { $g element create line$idx -label "Data $idx" -ydata data($idx) -fill $color -mapy $axis } $g grid configure -hide no $g axis configure x -min 0 -max 100 $g axis configure y -loose no -hide no -max 25 -title "Alpha" $g axis configure y2 -loose no -hide no -max 5 -title "Beta" $g axis configure y3 -loose no -hide no -title "Gamma" $g draw 15 15 $g destroy } DrawGraph mypdf write -file graph2.pdf mypdf destroy ====== [pdf4tcl_graph_example2.png%|% width= 861 height= 518] <>Package | PDF | Graphics | Plotting