问题更新:我差不多了,只是缺少网格的虚线样式。
网格:[1100 600] 步栅:5 max-n-points:grid / 1 / step-grid x轴边界:20 Y边距:10
max-random:1000 n点:300
get-random-data: func[n p][
block: copy []
repeat i n [
append block RANDOM p
]
block
]
get-extremes: func[block][
extreme: none
foreach element block [
if none? extreme [
extreme: copy []
repeat i 2 [append extreme element]
]
if element > extreme/1 [
extreme/1: element
]
if element < extreme/2 [
extreme/2: element
]
]
extreme
]
data0: get-random-data n-points max-random
extremes: get-extremes data0
height: extremes/1 - extremes/2
ratio: (grid/2 - x-axis-border - (Y-margin * 2)) / height
data: copy []
foreach element skip data0 (n-points - max-n-points) [
append data to-integer (ratio * element)
]
plot: copy []
color: 0.0.0
append plot [
pen green line
]
x: 0
foreach y data [
append plot as-pair x (grid/2 - x-axis-border - Y-margin) - y
x: x + 5
]
main: layout [
origin 20x0
space 1x1
panel1: box 1100x580 black effect reduce [
'line-pattern 4 4
'grid 30x30 0x0 200.200.200
'draw plot
]
panel2: box 1100x0 black
panel3: box 1100x20 black
]
view main
===前问题
每个盒子之间的空间太大我无法绘制虚线网格,怎么做?
plot: copy []
color: 0.0.0
append plot [line-pattern 4 4]
repeat x 400 [
repeat y 200 [
append plot compose [
box (xy: 25 * as-pair x - 1 y - 1) (xy + 25)
]
]
]
main: layout [
origin 0x0
panel1: box 800x400 black effect reduce ['draw plot]
panel2: box 800x180 black
panel3: box 800x20 black
]
view main
答案 0 :(得分:1)
使用space关键字来控制间距
请参阅http://www.rebol.com/docs/view-guide.html#section-29
此外,您可以使用'网格绘制网格
“grid生成一个二维网格线。这是图形布局程序的一个有用背景。可选参数是:一个PAIR,指定网格线的水平和垂直间距,一个PAIR指定的偏移量第一行,表示水平和垂直线的厚度的PAIR,以及提供线条颜色的TUPLE。“