http://rosettacode.org/wiki/Compare_sorting_algorithms'_performance
I've used character cell graphics because my best attempt with plot was
unsatisfactory. With following the key is glorious but the curves'
colors and symbols are all the same. I'm using j7.
require 'plot'
curve =: 3 : 0"2 1 2
pd 'type line'
pd ([ ; d3 p. [)/y
pd 'type marker'
pd ;/y
:
'mrk clr alg' =. x
pd 'type line'
pd 'color ',clr
pd ([ ; d3 p. [)/y
pd 'type marker'
pd 'markers ',mrk
pd ;/y
pd 'key ',alg
)
plt=: 4 : 0 NB. title plt data
'title label' =. ;:x
pd 'reset'
markers =. ;:'diamond square circle triangle plus times'
colors =. ;:'blue red green purple pink brown'
algorithms =. 'bubble insertion shell quick radix builtin'
if. 4 = 3 do.
(markers,.colors,.;:algorithms)&curve@(#"1~ 0 < {.)"2 y
else.
curve@(#"1~ 0 < {.)"2 y
end.
pd 'title j: comparison of sorting algorithms ',title
pd 'xcaption ^.length'
pd 'ycaption ^.',label
pd 'keypos rbi'
pd 'keystyle marker'
pd 'key ',algorithms
pd 'show'
)
'ones time' plt l ,: & (0&{)"2 t
'reverse time' plt l ,: & (1&{)"2 t
'random time' plt l ,: & (2&{)"2 t
'ones space' plt l ,: & (0&{)"2 s
'reverse space' plt l ,: & (1&{)"2 s
'random space' plt l ,: & (2&{)"2 s
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm