SELECT m::int AS month, y::int AS year, market::float AS market, acme::float AS acme
FROM EXTERNAL CSV("http://scleraviz.herokuapp.com/assets/data/acme.csv") TEXT parse "(\\d+)/(\\d+)" IN month TO (m, y)
PLOT(GEOM=BAR(x=month, y=market))
PLOT(
GEOM=bar(x=month, y=acme),
FILL=((acme > 0 AND market > 0) OR (acme <= 0 AND market <= 0))
SCALE=COLOR(true AS "orange", false AS "black")
LEGEND(LABELS=(true AS "SAME", false AS "OPPOSITE"))
)
FACET(ROWS=year)
Plots two monthly excess returns, as separate bar charts. This pair of plots is faceted on the year. The `acme' returns are coloured based on whether they are on the same side as the market returns, or on the opposite side. Shows that multiple plots can be faceted.
The data is read from a URL. The date is in an unusual format, and is explicily parsed using the `TEXT parse` operator which extracts the month and year based on the provided pattern. These and other column values are then cast to the appropriate data types.
"id","month","market","acme"
"1","1/86",-0.061134,0.03016
"2","2/86",0.00822,-0.165457
"3","3/86",-0.007381,0.080137
"4","4/86",-0.067561,-0.109917
"5","5/86",-0.006238,-0.114853
"6","6/86",-0.044251,-0.099254
"7","7/86",-0.11207,-0.226846
"8","8/86",0.030226,0.073445
"9","9/86",-0.129556,-0.143064
"10","10/86",0.001319,0.034776
"11","11/86",-0.033679,-0.063375
"12","12/86",-0.072795,-0.058735
"13","1/87",0.073396,0.050214
"14","2/87",-0.011618,0.111165
"15","3/87",-0.026852,-0.127492
"16","4/87",-0.040356,0.054522
"17","5/87",-0.047539,-0.072918
"18","6/87",-0.001732,-0.058979
"19","7/87",-0.008899,0.236147
"20","8/87",-0.020837,-0.094778
"21","9/87",-0.084811,-0.135669
"22","10/87",-0.262077,-0.284796
"23","11/87",-0.110167,-0.171494
"24","12/87",0.034955,0.242616
"25","1/88",0.012688,-0.063518
"26","2/88",-0.00217,-0.117677
"27","3/88",-0.073462,0.201674
"28","4/88",-0.043419,-0.147728
"29","5/88",-0.05473,-0.170885
"30","6/88",-0.011755,-0.014893
"31","7/88",-0.061718,-0.110515
"32","8/88",-0.10171,-0.168769
"33","9/88",-0.032705,-0.135585
"34","10/88",-0.045334,-0.084077
"35","11/88",-0.079288,-0.16455
"36","12/88",-0.036233,0.150269
"37","1/89",-0.011494,-0.015672
"38","2/89",-0.093729,-0.03786
"39","3/89",-0.065215,-0.074712
"40","4/89",-0.037113,-0.10853
"41","5/89",-0.044399,-0.036769
"42","6/89",-0.084412,0.023912
"43","7/89",0.003444,-0.07843
"44","8/89",-0.05676,-0.132199
"45","9/89",-0.07897,-0.110141
"46","10/89",-0.105367,-0.126302
"47","11/89",-0.038634,-0.09573
"48","12/89",-0.043261,0.06574
"49","1/90",-0.139773,-0.120056
"50","2/90",-0.059094,-0.085205
"51","3/90",-0.057736,-0.130433
"52","4/90",-0.102524,-0.116728
"53","5/90",0.023881,-0.078039
"54","6/90",-0.079116,-0.170322
"55","7/90",-0.078965,-0.077727
"56","8/90",-0.161359,-0.277035
"57","9/90",-0.119376,-0.207595
"58","10/90",-0.076008,-0.070515
"59","11/90",-0.006444,-0.046274
"60","12/90",-0.026401,-0.190834