tioga 1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Tioga_README +372 -0
- data/lgpl.txt +504 -0
- data/split/Dtable/defs.h +33 -0
- data/split/Dtable/dtable.c +1928 -0
- data/split/Dtable/dtable_intern.h +144 -0
- data/split/Dtable/dvector.h +61 -0
- data/split/Dtable/extconf.rb +4 -0
- data/split/Dtable/include/dtable.h +35 -0
- data/split/Dtable/lib/Dtable_extras.rb +90 -0
- data/split/Dtable/namespace.h +47 -0
- data/split/Dtable/safe_double.h +104 -0
- data/split/Dtable/symbols.c +92 -0
- data/split/Dtable/symbols.h +52 -0
- data/split/Dvector/defs.h +33 -0
- data/split/Dvector/dvector.c +5486 -0
- data/split/Dvector/dvector_intern.h +142 -0
- data/split/Dvector/extconf.rb +4 -0
- data/split/Dvector/include/dvector.h +61 -0
- data/split/Dvector/lib/Dvector_extras.rb +328 -0
- data/split/Dvector/lib/Numeric_extras.rb +134 -0
- data/split/Dvector/namespace.h +47 -0
- data/split/Dvector/safe_double.h +104 -0
- data/split/Dvector/symbols.c +92 -0
- data/split/Dvector/symbols.h +52 -0
- data/split/Flate/defs.h +33 -0
- data/split/Flate/extconf.rb +19 -0
- data/split/Flate/flate.c +156 -0
- data/split/Flate/flate_intern.h +97 -0
- data/split/Flate/include/flate.h +98 -0
- data/split/Flate/namespace.h +47 -0
- data/split/Flate/safe_double.h +104 -0
- data/split/Flate/symbols.c +92 -0
- data/split/Flate/symbols.h +52 -0
- data/split/Function/defs.h +33 -0
- data/split/Function/dvector.h +61 -0
- data/split/Function/extconf.rb +4 -0
- data/split/Function/function.c +988 -0
- data/split/Function/joint_qsort.c +258 -0
- data/split/Function/lib/Function_extras.rb +44 -0
- data/split/Function/namespace.h +47 -0
- data/split/Function/safe_double.h +104 -0
- data/split/Function/symbols.c +92 -0
- data/split/Function/symbols.h +52 -0
- data/split/Tioga/axes.c +774 -0
- data/split/Tioga/defs.h +33 -0
- data/split/Tioga/dtable.h +35 -0
- data/split/Tioga/dvector.h +61 -0
- data/split/Tioga/extconf.rb +4 -0
- data/split/Tioga/figures.c +672 -0
- data/split/Tioga/figures.h +855 -0
- data/split/Tioga/flate.h +98 -0
- data/split/Tioga/init.c +524 -0
- data/split/Tioga/lib/Arcs_and_Circles.rb +64 -0
- data/split/Tioga/lib/ColorConstants.rb +274 -0
- data/split/Tioga/lib/Colorbars.rb +10 -0
- data/split/Tioga/lib/Colormaps.rb +105 -0
- data/split/Tioga/lib/Coordinate_Conversions.rb +194 -0
- data/split/Tioga/lib/Creating_Paths.rb +94 -0
- data/split/Tioga/lib/Doc.rb +91 -0
- data/split/Tioga/lib/Executive.rb +515 -0
- data/split/Tioga/lib/FigMkr.rb +2224 -0
- data/split/Tioga/lib/FigureConstants.rb +125 -0
- data/split/Tioga/lib/Figures_and_Plots.rb +268 -0
- data/split/Tioga/lib/Images.rb +278 -0
- data/split/Tioga/lib/Legends.rb +190 -0
- data/split/Tioga/lib/MarkerConstants.rb +122 -0
- data/split/Tioga/lib/Markers.rb +129 -0
- data/split/Tioga/lib/Page_Frame_Bounds.rb +567 -0
- data/split/Tioga/lib/Rectangles.rb +94 -0
- data/split/Tioga/lib/Shading.rb +100 -0
- data/split/Tioga/lib/Special_Paths.rb +307 -0
- data/split/Tioga/lib/Strokes.rb +129 -0
- data/split/Tioga/lib/TeX_Text.rb +454 -0
- data/split/Tioga/lib/TexPreamble.rb +358 -0
- data/split/Tioga/lib/Titles_and_Labels.rb +306 -0
- data/split/Tioga/lib/Transparency.rb +89 -0
- data/split/Tioga/lib/Using_Paths.rb +164 -0
- data/split/Tioga/lib/Utils.rb +74 -0
- data/split/Tioga/lib/X_and_Y_Axes.rb +749 -0
- data/split/Tioga/lib/irb_tioga.rb +122 -0
- data/split/Tioga/lib/tioga.rb +1 -0
- data/split/Tioga/lib/tioga_ui.rb +5 -0
- data/split/Tioga/lib/tioga_ui_cmds.rb +793 -0
- data/split/Tioga/makers.c +989 -0
- data/split/Tioga/mk_tioga_sty.rb +53 -0
- data/split/Tioga/namespace.h +47 -0
- data/split/Tioga/pdf_font_dicts.c +18253 -0
- data/split/Tioga/pdfcolor.c +486 -0
- data/split/Tioga/pdfcoords.c +505 -0
- data/split/Tioga/pdffile.c +342 -0
- data/split/Tioga/pdfimage.c +536 -0
- data/split/Tioga/pdfpath.c +914 -0
- data/split/Tioga/pdfs.h +229 -0
- data/split/Tioga/pdftext.c +443 -0
- data/split/Tioga/safe_double.h +104 -0
- data/split/Tioga/symbols.c +92 -0
- data/split/Tioga/symbols.h +52 -0
- data/split/Tioga/texout.c +380 -0
- data/split/defs.h +33 -0
- data/split/extconf.rb +107 -0
- data/split/mkmf2.rb +1612 -0
- data/split/namespace.h +47 -0
- data/split/safe_double.h +104 -0
- data/split/scripts/tioga +4 -0
- data/split/symbols.c +92 -0
- data/split/symbols.h +52 -0
- data/tests/dtable_test.data +6 -0
- data/tests/dvector_read_test.data +1 -0
- data/tests/dvector_test.data +101 -0
- data/tests/tc_Dtable.rb +221 -0
- data/tests/tc_Dvector.rb +791 -0
- data/tests/tc_FMkr.rb +162 -0
- data/tests/tc_Flate.rb +45 -0
- data/tests/tc_Function.rb +111 -0
- data/tests/ts_Tioga.rb +38 -0
- metadata +163 -0
@@ -0,0 +1,94 @@
|
|
1
|
+
# Rectangles.rb
|
2
|
+
|
3
|
+
module Tioga
|
4
|
+
|
5
|
+
# These are the methods for creating and using rectangular paths for PDF graphics operations.
|
6
|
+
|
7
|
+
class Rectangles < Doc < FigureMaker
|
8
|
+
|
9
|
+
# Add a rectangle with corners at (_x_, _y_), (_x_ + _width_, _y_),
|
10
|
+
# (_x_ + _width_, _y_ + _height_), and (_x_, _y_ + _height_).
|
11
|
+
def append_rect_to_path(x, y, width, height)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Calls append_rect_to_path followed by #fill.
|
15
|
+
def fill_rect(x, y, width, height)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Calls append_rect_to_path followed by #stroke.
|
19
|
+
def stroke_rect(x, y, width, height)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Calls append_rect_to_path followed by fill_and_stroke.
|
23
|
+
def fill_and_stroke_rect(x, y, width, height)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Calls append_rect_to_path followed by #clip.
|
27
|
+
def clip_rect(x, y, width, height)
|
28
|
+
end
|
29
|
+
|
30
|
+
# :call-seq:
|
31
|
+
# append_frame_to_path
|
32
|
+
#
|
33
|
+
# Calls append_rect_to_path with the current frame rectangle.
|
34
|
+
def append_frame_to_path
|
35
|
+
end
|
36
|
+
|
37
|
+
# :call-seq:
|
38
|
+
# stroke_frame
|
39
|
+
#
|
40
|
+
# Calls append_frame_to_path followed by #stroke.
|
41
|
+
def stroke_frame
|
42
|
+
end
|
43
|
+
|
44
|
+
# :call-seq:
|
45
|
+
# fill_frame
|
46
|
+
#
|
47
|
+
# Calls append_frame_to_path followed by #fill.
|
48
|
+
def fill_frame
|
49
|
+
end
|
50
|
+
|
51
|
+
# :call-seq:
|
52
|
+
# fill_and_stroke_frame
|
53
|
+
#
|
54
|
+
# Calls append_frame_to_path followed by fill_and_stroke.
|
55
|
+
def fill_and_stroke_frame
|
56
|
+
end
|
57
|
+
|
58
|
+
# :call-seq:
|
59
|
+
# clip_to_frame
|
60
|
+
#
|
61
|
+
# Calls append_frame_to_path followed by #clip.
|
62
|
+
def clip_to_frame
|
63
|
+
end
|
64
|
+
|
65
|
+
# Like append_rect_to_path, but with corners rounded with
|
66
|
+
# curvatures given by _dx_ and _dy_.
|
67
|
+
#
|
68
|
+
# The illustration shows a rounded rectangle stroked and used as a clipping path
|
69
|
+
# for showing the image.
|
70
|
+
#
|
71
|
+
# http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/append_rounded_rect.jpg
|
72
|
+
#
|
73
|
+
def append_rounded_rect_to_path(x, y, width, height, dx, dy)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Calls append_rounded_rect_to_path followed by #clip.
|
77
|
+
def clip_rounded_rect(x, y, width, height, dx, dy)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Calls append_rounded_rect_to_path followed by #fill.
|
81
|
+
def fill_rounded_rect(x, y, width, height, dx, dy)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Calls append_rounded_rect_to_path followed by #stroke.
|
85
|
+
def stroke_rounded_rect(x, y, width, height, dx, dy)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Calls append_rounded_rect_to_path followed by fill_and_stroke.
|
89
|
+
def fill_and_stroke_rounded_rect(x, y, width, height, dx, dy)
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
end # class
|
94
|
+
end # module Tioga
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# Shading.rb
|
2
|
+
|
3
|
+
module Tioga
|
4
|
+
|
5
|
+
# These are the methods for doing shaded regions in PDF graphics.
|
6
|
+
|
7
|
+
class Shading < Doc < FigureMaker
|
8
|
+
|
9
|
+
=begin rdoc
|
10
|
+
Draws a color blend that varies along a linear axis between two endpoints and extends indefinitely perpendicular to that axis to the limits of the current clipping region. The color sequence is given by a colormap such as produced by create_colormap. Color position 0.0 of the colormap
|
11
|
+
goes at the start point, color position 1.0 of the colormap goes at the end point, and the intermediate colors are
|
12
|
+
placed at the corresponding intermediate locations along the line joining the start point to the end point.
|
13
|
+
|
14
|
+
If the 'extend_start' flag is +true+, then the start color is extended indefinitely beyond the start point to the
|
15
|
+
limits of the clipping region. Similarly, if the 'extend_end' flag is +true+, the end color is extended
|
16
|
+
indefinitely beyond the end point.
|
17
|
+
|
18
|
+
See also radial_shading.
|
19
|
+
|
20
|
+
Dictionary Entries
|
21
|
+
'x_start' => a_float # x coordinate of the start of the gradient
|
22
|
+
'y_start' => a_float # y coordinate of the start of the gradient
|
23
|
+
'start' => [ x_start, y_start ] # coordinates of the start of the gradient
|
24
|
+
'start_point' # alias for 'start'
|
25
|
+
'x_end' => a_float # x coordinate of the end of the gradient
|
26
|
+
'y_end' => a_float # y coordinate of the end of the gradient
|
27
|
+
'end' => [ x_end, y_end ] # coordinates of the end of the gradient
|
28
|
+
'end_point' # alias for 'end'
|
29
|
+
'colormap' => a_colormap # determines the shading
|
30
|
+
'color_map' # alias for 'colormap'
|
31
|
+
'extend_start' => true_or_false # default false
|
32
|
+
'extend_end' => true_or_false # default false
|
33
|
+
|
34
|
+
Example
|
35
|
+
|
36
|
+
def axial_shading
|
37
|
+
t.clip_rect(0, 0, 1, 1)
|
38
|
+
t.axial_shading(
|
39
|
+
'start_point' => [0, 0], 'end_point' => [1, 1],
|
40
|
+
'colormap' => t.mellow_colormap)
|
41
|
+
end
|
42
|
+
|
43
|
+
http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Axial_Shading.jpg
|
44
|
+
|
45
|
+
=end
|
46
|
+
def axial_shading(dict)
|
47
|
+
end
|
48
|
+
|
49
|
+
=begin rdoc
|
50
|
+
Draws a color blend that varies between two circles. The color sequence is given by a colormap such as produced by create_colormap. Color position 0.0 of the colormap
|
51
|
+
goes at the start circle, color position 1.0 of the colormap goes at the end circle, and the intermediate colors are
|
52
|
+
placed on corresponding intermediate circles. The circles can be stretched and rotated by the 'x_hat' and 'y_hat'
|
53
|
+
arguments which tell how to map unit vectors in x and y respectively.
|
54
|
+
|
55
|
+
If the 'extend_start' flag is +true+, then the start color is extended beyond the start circle. Similarly, if the 'extend_end' flag is +true+, the end color is extended beyond the end point. Note that either of the starting and ending circles may be larger than the other. If the shading is extended at the smaller end, the family of blend circles continues as far as the radius of the blend circle is greater than 0; if the shading is extended at the larger end, the blend circles continue until the radius of the blend circle is large enough to encompass the shading's entire bounding box. Extending the shading can thus cause painting to extend beyond the areas defined by the two circles themselves.
|
56
|
+
|
57
|
+
See also axial_shading.
|
58
|
+
|
59
|
+
Dictionary Entries
|
60
|
+
'x_start' => a_float # x coordinate of the center of the start circle
|
61
|
+
'y_start' => a_float # y coordinate of the center of the start circle
|
62
|
+
'radius_start' => a_float # the radius of the start circle
|
63
|
+
'start_radius' # alias for 'radius_start'
|
64
|
+
'start' => [ x_start, y_start, radius_start ]
|
65
|
+
'start_circle' # alias for 'start'
|
66
|
+
'x_end' => a_float # x coordinate of the center of the end circle
|
67
|
+
'y_end' => a_float # y coordinate of the center of the end circle
|
68
|
+
'radius_end' => a_float # the radius of the end circle
|
69
|
+
'end_radius' # alias for 'radius_end'
|
70
|
+
'end' => [ x_end, y_end, radius_end ]
|
71
|
+
'end_circle' # alias for 'end'
|
72
|
+
'colormap' => a_colormap # determines the shading
|
73
|
+
'color_map' # alias for 'colormap'
|
74
|
+
'x_hat' => [x, y] # default is [1, 0]
|
75
|
+
'xhat' # alias for 'x_hat'
|
76
|
+
'y_hat' => [x, y] # default is [0, 1]
|
77
|
+
'yhat' # alias for 'y_hat'
|
78
|
+
'extend_start' => true_or_false # default false
|
79
|
+
'extend_end' => true_or_false # default false
|
80
|
+
|
81
|
+
Example
|
82
|
+
|
83
|
+
def radial_shading
|
84
|
+
t.clip_rect(0, 0, 1, 1)
|
85
|
+
t.radial_shading(
|
86
|
+
'x_hat' => [0.5, 0.2], 'y_hat' => [0.0, 0.75],
|
87
|
+
'start_circle' => [0.75, 0.65, 0.9],
|
88
|
+
'end_circle' => [0.75, 0.65, 0.0],
|
89
|
+
'colormap' => t.intense_colormap,
|
90
|
+
'extend_start' => true)
|
91
|
+
end
|
92
|
+
|
93
|
+
http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Radial_Shading.jpg
|
94
|
+
=end
|
95
|
+
def radial_shading(dict)
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
end # class
|
100
|
+
end # module Tioga
|
@@ -0,0 +1,307 @@
|
|
1
|
+
# Special_Paths.rb
|
2
|
+
|
3
|
+
module Tioga
|
4
|
+
|
5
|
+
# These are the methods for creating and using various special paths including contours, splines, steps, arrows, and error bars.
|
6
|
+
|
7
|
+
class Special_Paths < Doc < FigureMaker
|
8
|
+
|
9
|
+
=begin rdoc
|
10
|
+
Creates a path following a contour in a two dimensional table of data using an algorithm from
|
11
|
+
Gri[http://gri.sourceforge.net/] done by Dan Kelley.
|
12
|
+
(There is also an option to use the
|
13
|
+
CONREC[http://local.wasp.uwa.edu.au/~pbourke/papers/conrec/] algorithm of Paul D. Bourke.)
|
14
|
+
See show_contour.
|
15
|
+
|
16
|
+
Dictionary Entries
|
17
|
+
'zs' => a_dtable # The data table
|
18
|
+
'data' # Alias for 'zs'
|
19
|
+
'xs' => a_dvector # The x figure coordinates for the columns of data
|
20
|
+
'ys' => a_dvector # The y figure coordinates for the rows of data
|
21
|
+
'legit' => a_dtable # Optional table, same size as zs, non-zero means corresponding data is okay.
|
22
|
+
'dest_xs' => a_dvector # The contour x values will be placed in this Dvector.
|
23
|
+
'dest_ys' => a_dvector # The contour y values will be placed in this Dvector.
|
24
|
+
'gaps' => an_array # Indices for gaps will be placed in this Array.
|
25
|
+
'z_level' => a_float # The contour level
|
26
|
+
'z' # Alias for 'z_level'
|
27
|
+
'level' # Alias for 'z_level'
|
28
|
+
'method' => a_string # (Optional) set to 'conrec' to use that algorithm instead of the one from Gri.
|
29
|
+
|
30
|
+
Example
|
31
|
+
|
32
|
+
levels = [9,10,11,12,13,14,15,16,17]
|
33
|
+
t.show_plot('boundaries' => bounds) do
|
34
|
+
clip_press_image
|
35
|
+
t.stroke_color = SlateGray
|
36
|
+
t.line_width = 1
|
37
|
+
dest_xs = Dvector.new; dest_ys = Dvector.new; gaps = Array.new
|
38
|
+
dict = { 'dest_xs' => dest_xs, 'dest_ys' => dest_ys, 'gaps' => gaps,
|
39
|
+
'xs' => @eos_logRHOs, 'ys' => @eos_logTs,
|
40
|
+
'data' => @pres_data }
|
41
|
+
levels.each do |level|
|
42
|
+
dict['level'] = level
|
43
|
+
t.make_contour(dict)
|
44
|
+
t.append_points_with_gaps_to_path(dest_xs, dest_ys, gaps, true)
|
45
|
+
t.stroke
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Contours.jpg
|
50
|
+
|
51
|
+
=end
|
52
|
+
def make_contour(dict)
|
53
|
+
end
|
54
|
+
|
55
|
+
=begin rdoc
|
56
|
+
Creates a 'staircase' path with steps matching the given data points.
|
57
|
+
|
58
|
+
Dictionary Entries
|
59
|
+
'xfirst' => a_float # x location for the start of the steps
|
60
|
+
'x_first' # Alias for 'xfirst'
|
61
|
+
'yfirst' => a_float # y location for the start of the steps
|
62
|
+
'y_first' # Alias for 'yfirst'
|
63
|
+
'xlast' => a_float # x location for the end of the steps
|
64
|
+
'x_last' # Alias for 'xlast'
|
65
|
+
'ylast' => a_float # y location for the end of the steps
|
66
|
+
'y_last' # Alias for 'ylast'
|
67
|
+
'xs' => a_dvector # The data x in figure coordinates
|
68
|
+
'ys' => a_dvector # The data y in figure coordinates
|
69
|
+
'dest_xs' => a_dvector # The x values for the steps will go here.
|
70
|
+
'dest_ys' => a_dvector # The y values for the steps will go here.
|
71
|
+
|
72
|
+
The widths of steps are determined by 'xfirst', 'xs', and 'xlast'; the heights of steps are
|
73
|
+
determined by 'yfirst', 'ys', and 'ylast'. The steps up and down occur at the midpoints between
|
74
|
+
the given x locations.
|
75
|
+
|
76
|
+
Example
|
77
|
+
|
78
|
+
def steps
|
79
|
+
t.do_box_labels("Steps", "Position", "Average Count")
|
80
|
+
xs = Dvector[ 1.0, 2.0, 5.0, 6.0, 7.0, 8.0, 10.0, 13.0, 17.0 ]
|
81
|
+
ys = Dvector[ 3.0, 3.7, 3.9, 4.2, 5.7, 6.6, 7.1, 6.7, 4.5 ]
|
82
|
+
data_pts = xs.size
|
83
|
+
x_first = 0.0; x_last = 18.0; y_first = y_last = 2.5
|
84
|
+
x_results = Dvector[]
|
85
|
+
y_results = Dvector[]
|
86
|
+
t.make_steps(
|
87
|
+
'xs' => xs, 'ys' => ys,
|
88
|
+
'dest_xs' => x_results, 'dest_ys' => y_results,
|
89
|
+
'x_first' => x_first, 'y_first' => y_first,
|
90
|
+
'x_last' => x_last, 'y_last' => y_last)
|
91
|
+
t.show_plot('boundaries' => [-1, 19, 8, 2]) do
|
92
|
+
t.fill_color = FloralWhite
|
93
|
+
t.fill_frame
|
94
|
+
t.stroke_color = Blue
|
95
|
+
t.append_points_to_path(x_results, y_results)
|
96
|
+
t.stroke
|
97
|
+
t.show_marker('Xs' => xs, 'Ys' => ys, 'marker' => Bullet,
|
98
|
+
'scale' => 0.6, 'color' => Red);
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Steps.jpg
|
103
|
+
=end
|
104
|
+
def make_steps(dict)
|
105
|
+
end
|
106
|
+
|
107
|
+
=begin rdoc
|
108
|
+
Creates an interpolated series of points smoothly connecting the given data points.
|
109
|
+
See also append_interpolant_to_path for creating smooth paths based on
|
110
|
+
Bezier curves rather than on sampled points joined by straight line segments.
|
111
|
+
|
112
|
+
Dictionary Entries
|
113
|
+
'start_slope' => a_float # optional
|
114
|
+
'end_slope' => a_float # optional
|
115
|
+
'xs' => a_dvector # The data x in figure coordinates
|
116
|
+
'ys' => a_dvector # The data y in figure coordinates
|
117
|
+
'sample_xs' => a_dvector # The x values where will interpolate
|
118
|
+
'result_ys' => a_dvector # The y values will be placed here.
|
119
|
+
|
120
|
+
A cubic spline interpolant is created (see make_interpolant) using 'start_slope', 'end_slope', 'xs', and
|
121
|
+
'ys'. At each x location in 'sample_xs', the interpolant is used to find the corresponding y location
|
122
|
+
which is then placed in the 'result_ys' vector. The results can passed to routines such as
|
123
|
+
append_points_to_path or show_polyline.
|
124
|
+
|
125
|
+
Example
|
126
|
+
|
127
|
+
def sampled_splines
|
128
|
+
t.do_box_labels("Sampled Splines", "Position", "Average Count")
|
129
|
+
xs = Dvector[ 1.0, 2.0, 5.0, 6.0, 7.0, 8.0, 10.0, 13.0, 17.0 ]
|
130
|
+
ys = Dvector[ 3.0, 3.7, 3.9, 4.2, 5.7, 6.6, 7.1, 6.7, 4.5 ]
|
131
|
+
data_pts = xs.size
|
132
|
+
x_first = 0.0; x_last = 18.0; y_first = y_last = 2.5
|
133
|
+
x_results = Dvector[]
|
134
|
+
y_results = Dvector[]
|
135
|
+
t.make_steps(
|
136
|
+
'dest_xs' => x_results, 'dest_ys' => y_results,
|
137
|
+
'xs' => xs, 'ys' => ys,
|
138
|
+
'x_first' => x_first, 'y_first' => y_first,
|
139
|
+
'x_last' => x_last, 'y_last' => y_last)
|
140
|
+
t.show_plot('boundaries' => [-1, 19, 8, 2]) do
|
141
|
+
t.fill_color = FloralWhite
|
142
|
+
t.fill_frame
|
143
|
+
smooth_pts = 4*(data_pts-1) + 1
|
144
|
+
dx = (xs[data_pts-1] - xs[0])/(smooth_pts-1)
|
145
|
+
sample_xs = Dvector.new(smooth_pts) { |i| i*dx + xs[0] }
|
146
|
+
result_ys = Dvector.new
|
147
|
+
t.make_spline_interpolated_points(
|
148
|
+
'sample_xs' => sample_xs, 'result_ys' => result_ys,
|
149
|
+
'xs' => xs, 'ys' => ys,
|
150
|
+
'start_slope' => 2.5*(ys[1]-ys[0])/(xs[1]-xs[0]))
|
151
|
+
t.stroke_color = Blue
|
152
|
+
t.append_points_to_path(sample_xs, result_ys)
|
153
|
+
t.stroke
|
154
|
+
t.show_marker('Xs' => sample_xs, 'Ys' => result_ys,
|
155
|
+
'marker' => Bullet, 'scale' => 0.4, 'color' => Green);
|
156
|
+
t.show_marker('Xs' => xs, 'Ys' => ys,
|
157
|
+
'marker' => Bullet, 'scale' => 0.6, 'color' => Red);
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Sampled_Splines.jpg
|
162
|
+
|
163
|
+
=end
|
164
|
+
def make_spline_interpolated_points(dict)
|
165
|
+
end
|
166
|
+
|
167
|
+
=begin rdoc
|
168
|
+
A cubic spline interpolant is created using 'start_slope', 'end_slope', 'xs', and
|
169
|
+
'ys'. The result can passed to append_interpolant_to_path or Dvector.spline_interpolate.
|
170
|
+
|
171
|
+
If 'start_slope' is given, it is used as the initial slope of the curve.
|
172
|
+
Otherwise, the starting slope is determined by the best fit with the starting second
|
173
|
+
derivative set to 0 (known as a "free" or "natural" spline). The 'end_slope' is
|
174
|
+
treated similarly.
|
175
|
+
|
176
|
+
Dictionary Entries
|
177
|
+
'start_slope' => a_float # optional
|
178
|
+
'end_slope' => a_float # optional
|
179
|
+
'xs' => a_dvector # The data x in figure coordinates
|
180
|
+
'ys' => a_dvector # The data y in figure coordinates
|
181
|
+
|
182
|
+
Example
|
183
|
+
|
184
|
+
def splines # append bezier curves
|
185
|
+
t.do_box_labels("Splines", "Position", "Average Count")
|
186
|
+
xs = Dvector[ 1.0, 2.0, 5.0, 6.0, 7.0, 8.0, 10.0, 13.0, 17.0 ]
|
187
|
+
ys = Dvector[ 3.0, 3.7, 3.9, 4.2, 5.7, 6.6, 7.1, 6.7, 4.5 ]
|
188
|
+
t.show_plot('boundaries' => [-1, 19, 8, 2]) do
|
189
|
+
t.fill_color = FloralWhite
|
190
|
+
t.fill_frame
|
191
|
+
start_slope = 2.5*(ys[1]-ys[0])/(xs[1]-xs[0])
|
192
|
+
interp = t.make_interpolant('xs' => xs, 'ys' => ys,
|
193
|
+
'start_slope' => start_slope)
|
194
|
+
t.append_interpolant_to_path(interp)
|
195
|
+
t.stroke_color = Black
|
196
|
+
t.stroke
|
197
|
+
t.show_marker('Xs' => xs, 'Ys' => ys,
|
198
|
+
'marker' => Bullet, 'scale' => 0.6, 'color' => Red);
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Splines.jpg
|
203
|
+
=end
|
204
|
+
def make_interpolant(dict)
|
205
|
+
end
|
206
|
+
|
207
|
+
# Appends a series of Bezier curves to the path based on the cubic spline interpolant _interp_.
|
208
|
+
# See make_interpolant.
|
209
|
+
def append_interpolant_to_path(interp)
|
210
|
+
end
|
211
|
+
|
212
|
+
# Calls #context, then, inside the new context, changes line_type and stroke_color (if those arguments are not +nil+),
|
213
|
+
# calls append_points_with_gaps_to_path, calls #stroke, and then saves the legend information (if _legend_
|
214
|
+
# is not +nil+).
|
215
|
+
def show_polyline(xs, ys, color = nil, legend = nil, type = nil, gaps = nil, close_subpaths = nil)
|
216
|
+
end
|
217
|
+
|
218
|
+
=begin rdoc
|
219
|
+
Calls show_polyline with the close_subpaths argument set to +false+. See make_contour.
|
220
|
+
|
221
|
+
Note: If you zoom in on a contour line, you'll discover that it
|
222
|
+
is made up of lots of very short, disconnected line segments. This may be a bug in
|
223
|
+
the implementation, or it may be inherent in the algorithm. I don't know which.
|
224
|
+
It only becomes a problem if you try to use dashes or dots to stroke the contour line.
|
225
|
+
The sequence of dashes and dots restarts at each section of the stroked line,
|
226
|
+
so. for contours, it is constantly restarting and never getting very far. The result
|
227
|
+
is definitely NOT what you'd expect.
|
228
|
+
|
229
|
+
Rather than using dots and dashes for contours, you might consider using different colors and line widths. For example,
|
230
|
+
you might make every N'th contour line thicker and darker to emphasize it.
|
231
|
+
=end rdoc
|
232
|
+
def show_contour(xs, ys, gaps = nil, color = nil, type = nil, legend = nil)
|
233
|
+
end
|
234
|
+
|
235
|
+
=begin rdoc
|
236
|
+
Draws error bars at the given point. The horizontal extent is given by 'dx' or by 'dx_plus' and 'dx_minus'
|
237
|
+
in case they are different. Similarly, the vertical extent is either 'dy' or 'dy_plus' and 'dy_minus'.
|
238
|
+
The 'end_cap' parameter specifies the length of end caps on the error bars in units of the text height.
|
239
|
+
|
240
|
+
Dictionary Entries
|
241
|
+
'x' => a_float # x coordinate of the point
|
242
|
+
'y' => a_float # x coordinate of the point
|
243
|
+
'dx' => a_float # horizontal error bar from x - dx to x + dx
|
244
|
+
'dy' => a_float # vertical error bar from y - dy to y + dy
|
245
|
+
'dx_plus' => a_float # horizontal error bar from x to x + dx_plus
|
246
|
+
'dx_minus' => a_float # horizontal error bar from x - dx_minus to x
|
247
|
+
'dy_plus' => a_float # vertical error bar from y to y + dy_plus
|
248
|
+
'dy_minus' => a_float # vertical error bar from y - dy_minus to y
|
249
|
+
'color' => a_color # default is Black.
|
250
|
+
'end_cap' => a_float # length in text heights (default is 0.15)
|
251
|
+
'line_width' => a_float # default is 1
|
252
|
+
|
253
|
+
=end
|
254
|
+
def show_error_bars(dict)
|
255
|
+
end
|
256
|
+
|
257
|
+
=begin rdoc
|
258
|
+
Draws an arrow connecting the given head and tail points and optionally adds head and tail markers
|
259
|
+
rotated to match the slope of the line.
|
260
|
+
|
261
|
+
Dictionary Entries
|
262
|
+
'x_head' => a_float # x coordinate of the head of the arrow
|
263
|
+
'y_head' => a_float # y coordinate of the head of the arrow
|
264
|
+
'head' => [ x_head, y_head ] # coordinates of the head of the arrow
|
265
|
+
'x_tail' => a_float # x coordinate of the tail of the arrow
|
266
|
+
'y_tail' => a_float # y coordinate of the tail of the arrow
|
267
|
+
'tail' => [ x_tail, y_tail ] # coordinates of the tail of the arrow
|
268
|
+
'line_width' => a_float # for the line joining head to tail
|
269
|
+
'head_marker' => a_marker # default is Arrowhead (use 'None' to omit)
|
270
|
+
'tail_marker' => a_marker # default is BarThin (use 'None' to omit)
|
271
|
+
'head_scale' => a_float # scale for head_marker
|
272
|
+
'tail_scale' => a_float # scale for tail_marker
|
273
|
+
'color' => a_color # default for the following colors
|
274
|
+
'head_color' => a_color # color for show_marker with head_marker
|
275
|
+
'tail_color' => a_color # color for show_marker with tail_marker
|
276
|
+
'line_color' => a_color # color for line from head to tail
|
277
|
+
|
278
|
+
Example: 't' in this is the default FigureMaker.
|
279
|
+
|
280
|
+
def show_arrows
|
281
|
+
t.stroke_rect(0,0,1,1)
|
282
|
+
center_x = 0.5; center_y = 0.5; len = 0.45
|
283
|
+
hls = t.rgb_to_hls(Red)
|
284
|
+
angles = 36
|
285
|
+
delta = 360.0/angles
|
286
|
+
angles.times do |angle|
|
287
|
+
angle *= delta
|
288
|
+
dx = len*cos(angle*RADIANS_PER_DEGREE)
|
289
|
+
dy = len*sin(angle*RADIANS_PER_DEGREE)
|
290
|
+
x = center_x + dx; y = center_y + dy
|
291
|
+
clr = t.hls_to_rgb([angle, hls[1], hls[2]])
|
292
|
+
t.show_arrow(
|
293
|
+
'head' => [x,y],
|
294
|
+
'tail'=> [center_x, center_y],
|
295
|
+
'head_scale' => 1.5,
|
296
|
+
'tail_marker' => 'None',
|
297
|
+
'head_color' => clr)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Arrows.jpg
|
302
|
+
=end
|
303
|
+
def show_arrow(dict)
|
304
|
+
end
|
305
|
+
|
306
|
+
end # class
|
307
|
+
end # module Tioga
|