Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.25 KB | None | 0 0
  1. {
  2. "name": "boxplot",
  3. "height": 200,
  4. "padding": "auto",
  5. "width": 600,
  6. "signals": [
  7. {
  8. "name": "boxSize",
  9. "init": 40
  10. }
  11. ],
  12. "axes": [
  13. {
  14. "type": "x",
  15. "scale": "x"
  16. },
  17. {
  18. "offset": 5,
  19. "properties": {
  20. "axis": {
  21. "stroke": {
  22. "value": "transparent"
  23. }
  24. }
  25. },
  26. "type": "y",
  27. "scale": "y",
  28. "tickSize": 0
  29. }
  30. ],
  31. "scales": [
  32. {
  33. "name": "y",
  34. "points": true,
  35. "padding": 1.5,
  36. "range": "height",
  37. "domain": {
  38. "data": "table",
  39. "field": "x"
  40. },
  41. "type": "ordinal",
  42. "round": true
  43. },
  44. {
  45. "name": "x",
  46. "nice": true,
  47. "range": "width",
  48. "domain": {
  49. "data": "table",
  50. "field": [
  51. "y"
  52. ]
  53. },
  54. "type": "linear",
  55. "round": true
  56. }
  57. ],
  58. "data": [
  59. {
  60. "name": "table",
  61. "values": [
  62. {
  63. "x": 6,
  64. "y2": 0,
  65. "group": 1,
  66. "y": 21
  67. },
  68. {
  69. "x": 6,
  70. "y2": 0,
  71. "group": 1,
  72. "y": 21
  73. },
  74. {
  75. "x": 4,
  76. "y2": 0,
  77. "group": 1,
  78. "y": 22.8
  79. },
  80. {
  81. "x": 6,
  82. "y2": 0,
  83. "group": 1,
  84. "y": 21.4
  85. },
  86. {
  87. "x": 8,
  88. "y2": 0,
  89. "group": 1,
  90. "y": 18.7
  91. },
  92. {
  93. "x": 6,
  94. "y2": 0,
  95. "group": 1,
  96. "y": 18.1
  97. },
  98. {
  99. "x": 8,
  100. "y2": 0,
  101. "group": 1,
  102. "y": 14.3
  103. },
  104. {
  105. "x": 4,
  106. "y2": 0,
  107. "group": 1,
  108. "y": 24.4
  109. },
  110. {
  111. "x": 4,
  112. "y2": 0,
  113. "group": 1,
  114. "y": 22.8
  115. },
  116. {
  117. "x": 6,
  118. "y2": 0,
  119. "group": 1,
  120. "y": 19.2
  121. },
  122. {
  123. "x": 6,
  124. "y2": 0,
  125. "group": 1,
  126. "y": 17.8
  127. },
  128. {
  129. "x": 8,
  130. "y2": 0,
  131. "group": 1,
  132. "y": 16.4
  133. },
  134. {
  135. "x": 8,
  136. "y2": 0,
  137. "group": 1,
  138. "y": 17.3
  139. },
  140. {
  141. "x": 8,
  142. "y2": 0,
  143. "group": 1,
  144. "y": 15.2
  145. },
  146. {
  147. "x": 8,
  148. "y2": 0,
  149. "group": 1,
  150. "y": 10.4
  151. },
  152. {
  153. "x": 8,
  154. "y2": 0,
  155. "group": 1,
  156. "y": 10.4
  157. },
  158. {
  159. "x": 8,
  160. "y2": 0,
  161. "group": 1,
  162. "y": 14.7
  163. },
  164. {
  165. "x": 4,
  166. "y2": 0,
  167. "group": 1,
  168. "y": 32.4
  169. },
  170. {
  171. "x": 4,
  172. "y2": 0,
  173. "group": 1,
  174. "y": 30.4
  175. },
  176. {
  177. "x": 4,
  178. "y2": 0,
  179. "group": 1,
  180. "y": 33.9
  181. },
  182. {
  183. "x": 4,
  184. "y2": 0,
  185. "group": 1,
  186. "y": 21.5
  187. },
  188. {
  189. "x": 8,
  190. "y2": 0,
  191. "group": 1,
  192. "y": 15.5
  193. },
  194. {
  195. "x": 8,
  196. "y2": 0,
  197. "group": 1,
  198. "y": 15.2
  199. },
  200. {
  201. "x": 8,
  202. "y2": 0,
  203. "group": 1,
  204. "y": 13.3
  205. },
  206. {
  207. "x": 8,
  208. "y2": 0,
  209. "group": 1,
  210. "y": 19.2
  211. },
  212. {
  213. "x": 4,
  214. "y2": 0,
  215. "group": 1,
  216. "y": 27.3
  217. },
  218. {
  219. "x": 4,
  220. "y2": 0,
  221. "group": 1,
  222. "y": 26
  223. },
  224. {
  225. "x": 4,
  226. "y2": 0,
  227. "group": 1,
  228. "y": 30.4
  229. },
  230. {
  231. "x": 8,
  232. "y2": 0,
  233. "group": 1,
  234. "y": 15.8
  235. },
  236. {
  237. "x": 6,
  238. "y2": 0,
  239. "group": 1,
  240. "y": 19.7
  241. },
  242. {
  243. "x": 8,
  244. "y2": 0,
  245. "group": 1,
  246. "y": 15
  247. },
  248. {
  249. "x": 4,
  250. "y2": 0,
  251. "group": 1,
  252. "y": 21.4
  253. }
  254. ]
  255. },
  256. {
  257. "name": "stats",
  258. "source": "table",
  259. "transform": [
  260. {
  261. "type": "aggregate",
  262. "groupby": [
  263. "x"
  264. ],
  265. "summarize": {
  266. "y": ["min","max", "median", "q1", "q3", "valid"]
  267. }
  268. }
  269. ]
  270. },
  271. {
  272. "name": "iqrcalcs",
  273. "source": "stats",
  274. "transform": [{"type": "formula", "field": "lower", "expr": "max(datum.min_y,datum.q1_y-1.58*(datum.q3_y-datum.q1_y))"},
  275. {"type": "formula", "field": "upper", "expr": "min(datum.max_y,datum.q3_y+1.58*(datum.q3_y-datum.q1_y))"}]
  276. }
  277. ],
  278. "marks": [
  279. {
  280. "properties": {
  281. "enter": {
  282. "height": {
  283. "value": 1
  284. },
  285. "x2": {
  286. "field": "upper",
  287. "scale": "x"
  288. },
  289. "x": {
  290. "field": "lower",
  291. "scale": "x"
  292. },
  293. "yc": {
  294. "field": "x",
  295. "scale": "y"
  296. },
  297. "fill": {
  298. "value": "#888"
  299. }
  300. }
  301. },
  302. "from": {
  303. "data": "iqrcalcs"
  304. },
  305. "type": "rect"
  306. },
  307. {
  308. "type": "rect",
  309. "from": {"data": "iqrcalcs"},
  310. "properties": {
  311. "enter": {
  312. "x": {"scale": "x", "field": "q1_y"},
  313. "x2": {"scale": "x", "field": "q3_y"},
  314. "yc": {"scale": "y", "field": "x"},
  315. "height": {"signal": "boxSize"},
  316. "fill": {"value": "green"},
  317. "stroke": {"value": "#888"}
  318. }
  319. }
  320. },
  321. {
  322. "type": "rect",
  323. "from": {"data": "iqrcalcs"},
  324. "properties": {
  325. "enter": {
  326. "x": {"scale": "x", "field": "median_y"},
  327. "width": {"value": 2},
  328. "yc": {"scale": "y", "field": "x"},
  329. "height": {"signal": "boxSize"},
  330. "fill": {"value": "#000"}
  331. }
  332. }
  333. },
  334. {
  335. "type": "rect",
  336. "from": {"data": "iqrcalcs"},
  337. "properties": {
  338. "enter": {
  339. "x": {"scale": "x", "field": "lower"},
  340. "width": {"value": 1},
  341. "yc": {"scale": "y", "field": "x"},
  342. "height": {"signal": "boxSize", "mult": 0.5},
  343. "fill": {"value": "#000"}
  344. }
  345. }
  346. },
  347. {
  348. "type": "rect",
  349. "from": {"data": "iqrcalcs"},
  350. "properties": {
  351. "enter": {
  352. "x": {"scale": "x", "field": "upper"},
  353. "width": {"value": 1},
  354. "yc": {"scale": "y", "field": "x"},
  355. "height": {"signal": "boxSize", "mult": 0.5},
  356. "fill": {"value": "#000"}
  357. }
  358. }
  359. },
  360. {
  361. "type": "symbol",
  362. "from": {"data": "stats"},
  363. "properties": {
  364. "enter": {
  365. "x": {"scale": "x", "field": "min_y"},
  366. "yc": {"scale": "y", "field": "x"},
  367. "size": {"value": 20},
  368. "stroke": {"value": "#000"},
  369. "fill": {"value": "#fff"}
  370.  
  371. }
  372. }
  373. },
  374. {
  375. "type": "symbol",
  376. "from": {"data": "stats"},
  377. "properties": {
  378. "enter": {
  379. "x": {"scale": "x", "field": "max_y"},
  380. "yc": {"scale": "y", "field": "x"},
  381. "size": {"value": 20},
  382. "stroke": {"value": "#000"},
  383. "fill": {"value": "#fff"}
  384.  
  385. }
  386. }
  387. }
  388. ]
  389. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement