View Source Changelog

v0.3.1 (2024-01-20)

Added plot options

v0.3.0 (2024-01-03)

Added

  • Nx support, you can pass directly tensors as data series.
x = Nx.linspace(-20, 20, n: 200)
y = Nx.pow(x, 2)

Tucan.lineplot([x: x, y: y], "x", "y", width: 400)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","data":{"values":[{"x":-20.0,"y":400.0},{"x":-19.798994064331055,"y":392.0001525878906},{"x":-19.597990036010742,"y":384.0812072753906},{"x":-19.396984100341797,"y":376.24298095703125},{"x":-19.195980072021484,"y":368.48565673828125},{"x":-18.99497413635254,"y":360.8090515136719},{"x":-18.793970108032227,"y":353.21331787109375},{"x":-18.59296417236328,"y":345.69830322265625},{"x":-18.39196014404297,"y":338.2641906738281},{"x":-18.190954208374023,"y":330.91082763671875},{"x":-17.98995018005371,"y":323.6383056640625},{"x":-17.788944244384766,"y":316.446533203125},{"x":-17.587940216064453,"y":309.33563232421875},{"x":-17.386934280395508,"y":302.30548095703125},{"x":-17.185930252075195,"y":295.356201171875},{"x":-16.98492431640625,"y":288.4876403808594},{"x":-16.783920288085938,"y":281.6999816894531},{"x":-16.582914352416992,"y":274.9930419921875},{"x":-16.38191032409668,"y":268.3669738769531},{"x":-16.180904388427734,"y":261.8216552734375},{"x":-15.979899406433105,"y":255.357177734375},{"x":-15.778894424438477,"y":248.9735107421875},{"x":-15.577889442443848,"y":242.67063903808594},{"x":-15.376884460449219,"y":236.44857788085938},{"x":-15.17587947845459,"y":230.30731201171875},{"x":-14.974874496459961,"y":224.2468719482422},{"x":-14.773869514465332,"y":218.26722717285156},{"x":-14.572864532470703,"y":212.36837768554688},{"x":-14.371858596801758,"y":206.55032348632812},{"x":-14.170854568481445,"y":200.81312561035156},{"x":-13.9698486328125,"y":195.15667724609375},{"x":-13.768844604492188,"y":189.58108520507812},{"x":-13.567838668823242,"y":184.08624267578125},{"x":-13.36683464050293,"y":178.67227172851562},{"x":-13.165828704833984,"y":173.33905029296875},{"x":-12.964824676513672,"y":168.08668518066406},{"x":-12.763818740844727,"y":162.91506958007812},{"x":-12.562814712524414,"y":157.82431030273438},{"x":-12.361808776855469,"y":152.81431579589844},{"x":-12.16080379486084,"y":147.88514709472656},{"x":-11.959798812866211,"y":143.0367889404297},{"x":-11.758793830871582,"y":138.26922607421875},{"x":-11.557788848876953,"y":133.58248901367188},{"x":-11.356783866882324,"y":128.97654724121094},{"x":-11.155778884887695,"y":124.45140075683594},{"x":-10.954773902893066,"y":120.00707244873047},{"x":-10.753768920898438,"y":115.64354705810547},{"x":-10.552763938903809,"y":111.36082458496094},{"x":-10.35175895690918,"y":107.1589126586914},{"x":-10.15075397491455,"y":103.03780364990234},{"x":-9.949748992919922,"y":98.99750518798828},{"x":-9.748744010925293,"y":95.03800964355469},{"x":-9.547739028930664,"y":91.15931701660156},{"x":-9.346734046936035,"y":87.36143493652344},{"x":-9.14572811126709,"y":83.64434051513672},{"x":-8.944723129272461,"y":80.00807189941406},{"x":-8.743718147277832,"y":76.45260620117188},{"x":-8.542713165283203,"y":72.97795104980469},{"x":-8.341708183288574,"y":69.58409881591797},{"x":-8.140703201293945,"y":66.27104949951172},{"x":-7.939698219299316,"y":63.0388069152832},{"x":-7.7386932373046875,"y":59.88737487792969},{"x":-7.537688255310059,"y":56.81674575805664},{"x":-7.33668327331543,"y":53.82691955566406},{"x":-7.135678291320801,"y":50.917903900146484},{"x":-6.934673309326172,"y":48.08969497680664},{"x":-6.733668327331543,"y":45.342288970947266},{"x":-6.532663345336914,"y":42.675689697265625},{"x":-6.331658363342285,"y":40.08989715576172},{"x":-6.130653381347656,"y":37.58491134643555},{"x":-5.929648399353027,"y":35.160728454589844},{"x":-5.728643417358398,"y":32.81735610961914},{"x":-5.5276384353637695,"y":30.554786682128906},{"x":-5.326633453369141,"y":28.373023986816406},{"x":-5.125628471374512,"y":26.27206802368164},{"x":-4.924622535705566,"y":24.251907348632812},{"x":-4.7236175537109375,"y":22.312562942504883},{"x":-4.522612571716309,"y":20.454025268554688},{"x":-4.32160758972168,"y":18.676292419433594},{"x":-4.120602607727051,"y":16.979366302490234},{"x":-3.919597625732422,"y":15.363245964050293},{"x":-3.7185935974121094,"y":13.827938079833984},{"x":-3.517587661743164,"y":12.373422622680664},{"x":-3.3165836334228516,"y":10.999727249145508},{"x":-3.1155776977539062,"y":9.70682430267334},{"x":-2.9145736694335938,"y":8.494739532470703},{"x":-2.7135677337646484,"y":7.363450050354004},{"x":-2.512561798095703,"y":6.312966823577881},{"x":-2.3115577697753906,"y":5.343299388885498},{"x":-2.1105518341064453,"y":4.4544291496276855},{"x":-1.9095478057861328,"y":3.6463727951049805},{"x":-1.7085418701171875,"y":2.9191153049468994},{"x":-1.507537841796875,"y":2.272670269012451},{"x":-1.3065319061279297,"y":1.7070256471633911},{"x":-1.1055278778076172,"y":1.2221919298171997},{"x":-0.9045219421386719,"y":0.8181599378585815},{"x":-0.7035179138183594,"y":0.4949374496936798},{"x":-0.5025119781494141,"y":0.25251829624176025},{"x":-0.30150794982910156,"y":0.09090704470872879},{"x":-0.10050201416015625,"y":0.010100655257701874},{"x":0.10050201416015625,"y":0.010100655257701874},{"x":0.30150794982910156,"y":0.09090704470872879},{"x":0.5025119781494141,"y":0.25251829624176025},{"x":0.7035179138183594,"y":0.4949374496936798},{"x":0.9045219421386719,"y":0.8181599378585815},{"x":1.1055278778076172,"y":1.2221919298171997},{"x":1.3065319061279297,"y":1.7070256471633911},{"x":1.507537841796875,"y":2.272670269012451},{"x":1.7085437774658203,"y":2.919121742248535},{"x":1.9095478057861328,"y":3.6463727951049805},{"x":2.110553741455078,"y":4.454437255859375},{"x":2.3115577697753906,"y":5.343299388885498},{"x":2.512563705444336,"y":6.312976360321045},{"x":2.7135677337646484,"y":7.363450050354004},{"x":2.9145736694335938,"y":8.494739532470703},{"x":3.1155776977539062,"y":9.70682430267334},{"x":3.3165836334228516,"y":10.999727249145508},{"x":3.517587661743164,"y":12.373422622680664},{"x":3.7185935974121094,"y":13.827938079833984},{"x":3.919597625732422,"y":15.363245964050293},{"x":4.120603561401367,"y":16.979373931884766},{"x":4.32160758972168,"y":18.676292419433594},{"x":4.522613525390625,"y":20.45403289794922},{"x":4.7236175537109375,"y":22.312562942504883},{"x":4.924623489379883,"y":24.251916885375977},{"x":5.125627517700195,"y":26.272056579589844},{"x":5.326633453369141,"y":28.373023986816406},{"x":5.527637481689453,"y":30.55477523803711},{"x":5.728643417358398,"y":32.81735610961914},{"x":5.929649353027344,"y":35.16073989868164},{"x":6.130653381347656,"y":37.58491134643555},{"x":6.331659317016602,"y":40.089908599853516},{"x":6.532663345336914,"y":42.675689697265625},{"x":6.733669281005859,"y":45.34230041503906},{"x":6.934673309326172,"y":48.08969497680664},{"x":7.135679244995117,"y":50.91791915893555},{"x":7.33668327331543,"y":53.82691955566406},{"x":7.537689208984375,"y":56.81675720214844},{"x":7.7386932373046875,"y":59.88737487792969},{"x":7.939699172973633,"y":63.038822174072266},{"x":8.140703201293945,"y":66.27104949951172},{"x":8.34170913696289,"y":69.58411407470703},{"x":8.542713165283203,"y":72.97795104980469},{"x":8.743719100952148,"y":76.45262145996094},{"x":8.944723129272461,"y":80.00807189941406},{"x":9.145729064941406,"y":83.64436340332031},{"x":9.346733093261719,"y":87.36141967773438},{"x":9.547739028930664,"y":91.15931701660156},{"x":9.748743057250977,"y":95.03799438476562},{"x":9.949748992919922,"y":98.99750518798828},{"x":10.150754928588867,"y":103.03782653808594},{"x":10.35175895690918,"y":107.1589126586914},{"x":10.552764892578125,"y":111.36084747314453},{"x":10.753768920898438,"y":115.64354705810547},{"x":10.954774856567383,"y":120.00709533691406},{"x":11.155778884887695,"y":124.45140075683594},{"x":11.35678482055664,"y":128.9765625},{"x":11.557788848876953,"y":133.58248901367188},{"x":11.758794784545898,"y":138.26925659179688},{"x":11.959798812866211,"y":143.0367889404297},{"x":12.160804748535156,"y":147.8851776123047},{"x":12.361808776855469,"y":152.81431579589844},{"x":12.562812805175781,"y":157.8242645263672},{"x":12.76382064819336,"y":162.9151153564453},{"x":12.964824676513672,"y":168.08668518066406},{"x":13.165828704833984,"y":173.33905029296875},{"x":13.366832733154297,"y":178.67221069335938},{"x":13.567840576171875,"y":184.0863037109375},{"x":13.768844604492188,"y":189.58108520507812},{"x":13.9698486328125,"y":195.15667724609375},{"x":14.170852661132812,"y":200.8130645751953},{"x":14.37186050415039,"y":206.5503692626953},{"x":14.572864532470703,"y":212.36837768554688},{"x":14.773868560791016,"y":218.26719665527344},{"x":14.974876403808594,"y":224.24691772460938},{"x":15.175880432128906,"y":230.30734252929688},{"x":15.376884460449219,"y":236.44857788085938},{"x":15.577888488769531,"y":242.6706085205078},{"x":15.77889633178711,"y":248.97357177734375},{"x":15.979900360107422,"y":255.35720825195312},{"x":16.180904388427734,"y":261.8216552734375},{"x":16.381908416748047,"y":268.3669128417969},{"x":16.582916259765625,"y":274.99310302734375},{"x":16.783920288085938,"y":281.6999816894531},{"x":16.98492431640625,"y":288.4876403808594},{"x":17.185928344726562,"y":295.35614013671875},{"x":17.38693618774414,"y":302.3055419921875},{"x":17.587940216064453,"y":309.33563232421875},{"x":17.788944244384766,"y":316.446533203125},{"x":17.989948272705078,"y":323.63824462890625},{"x":18.190956115722656,"y":330.910888671875},{"x":18.39196014404297,"y":338.2641906738281},{"x":18.59296417236328,"y":345.69830322265625},{"x":18.79397201538086,"y":353.21337890625},{"x":18.994976043701172,"y":360.8091125488281},{"x":19.195980072021484,"y":368.48565673828125},{"x":19.396984100341797,"y":376.24298095703125},{"x":19.597991943359375,"y":384.081298828125},{"x":19.798995971679688,"y":392.000244140625},{"x":20.0,"y":400.0}]},"encoding":{"x":{"field":"x","type":"quantitative"},"y":{"field":"y","type":"quantitative"}},"mark":{"fillOpacity":1,"type":"line"},"width":400}
image = Nx.tensor([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]], type: {:f, 32})

Tucan.imshow(image, show_scale: true, width: 200, height: 150)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","data":{"values":[{"v":1.0,"x":0,"y":0},{"v":2.0,"x":1,"y":0},{"v":3.0,"x":2,"y":0},{"v":4.0,"x":3,"y":0},{"v":5.0,"x":0,"y":1},{"v":6.0,"x":1,"y":1},{"v":7.0,"x":2,"y":1},{"v":8.0,"x":3,"y":1},{"v":9.0,"x":0,"y":2},{"v":10.0,"x":1,"y":2},{"v":11.0,"x":2,"y":2},{"v":12.0,"x":3,"y":2}]},"encoding":{"color":{"field":"v","legend":{"title":null},"scale":{"reverse":false,"scheme":"viridis"},"type":"quantitative"},"x":{"axis":null,"field":"x","type":"ordinal"},"y":{"axis":null,"field":"y","type":"ordinal"}},"height":150,"mark":"rect","width":200}
Tucan.errorbar(:barley, "yield", group_by: "variety", points: true, ticks: true)
|> Tucan.color_by("variety")
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","__tucan__":{"multilayer":true},"data":{"url":"https://vega.github.io/editor/data/barley.json"},"encoding":{"color":{"field":"variety"}},"layer":[{"encoding":{"x":{"field":"yield","scale":{"zero":false},"type":"quantitative"},"y":{"field":"variety","type":"nominal"}},"mark":{"extent":"stderr","fillOpacity":1,"ticks":true,"type":"errorbar"}},{"encoding":{"x":{"aggregate":"mean","field":"yield","type":"quantitative"},"y":{"field":"variety","type":"nominal"}},"mark":{"filled":true,"type":"point"}}]}
Tucan.errorband(:cars, "Year", "Miles_per_Gallon",
  extent: :ci,
  fill_color: "black",
  borders: true,
  x: [time_unit: "year", type: :temporal]
)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","data":{"url":"https://vega.github.io/editor/data/cars.json"},"encoding":{"x":{"field":"Year","scale":{"zero":false},"timeUnit":"year","type":"temporal"},"y":{"field":"Miles_per_Gallon","scale":{"zero":false},"type":"quantitative"}},"mark":{"borders":[],"color":"black","extent":"ci","fillOpacity":1,"type":"errorband"}}
data = [
  category: ["A", "B", "C", "D"],
  value: [90, 72, 81, 50, 64]
]

Tucan.lollipop(data, "category", "value",
  orient: :horizontal,
  point_color: "red",
  width: 300
)
|> Tucan.Scale.set_x_domain(30, 100)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","__tucan__":{"multilayer":true},"data":{"values":[{"category":"A","value":90},{"category":"B","value":72},{"category":"C","value":81},{"category":"D","value":50}]},"layer":[{"encoding":{"x":{"field":"value","scale":{"domain":[30,100]},"type":"quantitative"},"y":{"axis":{"labelAngle":0},"field":"category","type":"nominal"}},"mark":{"color":"black","type":"rule"}},{"encoding":{"x":{"field":"value","scale":{"domain":[30,100]},"type":"quantitative"},"y":{"axis":{"labelAngle":0},"field":"category","type":"nominal"}},"mark":{"color":"red","filled":true,"opacity":1,"size":60,"type":"point"}}],"width":300}
Tucan.layers([
  Tucan.Geometry.rectangle({-2, 10}, {7, -3}, line_color: "green"),
  Tucan.Geometry.rectangle({-3.5, 0.1}, {8.1, -4.2},
    fill_color: "pink",
    fill_opacity: 0.3
  ),
  Tucan.Geometry.polyline([{1, 1}, {2, 7}, {5, 3}],
    closed: true,
    fill_color: "green",
    fill_opacity: 0.3
  )
])
|> Tucan.Scale.set_xy_domain(-5, 11)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"data":{"values":[{"order":0,"x":-2,"y":-3},{"order":1,"x":-2,"y":10},{"order":2,"x":7,"y":10},{"order":3,"x":7,"y":-3},{"order":4,"x":-2,"y":-3}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-5,11]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,11]},"type":"quantitative"}},"mark":{"color":"green","fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"}},{"data":{"values":[{"order":0,"x":-3.5,"y":-4.2},{"order":1,"x":-3.5,"y":0.1},{"order":2,"x":8.1,"y":0.1},{"order":3,"x":8.1,"y":-4.2},{"order":4,"x":-3.5,"y":-4.2}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-5,11]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,11]},"type":"quantitative"}},"mark":{"fill":"pink","fillOpacity":0.3,"strokeOpacity":1,"strokeWidth":1,"type":"line"}},{"data":{"values":[{"order":0,"x":1,"y":1},{"order":1,"x":2,"y":7},{"order":2,"x":5,"y":3},{"order":3,"x":1,"y":1}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-5,11]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,11]},"type":"quantitative"}},"mark":{"fill":"green","fillOpacity":0.3,"strokeOpacity":1,"strokeWidth":1,"type":"line"}}]}
Tucan.scatter(:iris, "petal_width", "petal_length")
|> Tucan.Axes.set_orientation(:y, :right)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","data":{"url":"https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csv"},"encoding":{"x":{"field":"petal_width","scale":{"zero":false},"type":"quantitative"},"y":{"axis":{"orient":"right"},"field":"petal_length","scale":{"zero":false},"type":"quantitative"}},"mark":{"fillOpacity":1,"type":"point"}}

Added plot options

  • Support :point_shape, :point_size and :point_color in Tucan.stripplot/3.
  • Support uniform jittering through :jitter_mode in Tucan.Stripplot/3.
  • Support stacked mode in Tucan.density/3.

Changed

Deprecated

v0.2.1 (2023-10-17)

Added

  • Support conditional text color in heatmaps using the :text_color option.
Tucan.heatmap(:glue, "Task", "Model", "Score",
  annotate: true,
  text: [format: ".1f"],
  text_color: [{nil, 40, "black"}, {40, 80, "white"}, {60, nil, "yellow"}]
)
|> Tucan.set_size(250, 250)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","__tucan__":{"multilayer":true},"data":{"url":"https://raw.githubusercontent.com/mwaskom/seaborn-data/master/glue.csv"},"height":250,"layer":[{"encoding":{"color":{"aggregate":"mean","field":"Score","type":"quantitative"},"x":{"field":"Task","type":"nominal"},"y":{"field":"Model","type":"nominal"}},"mark":{"fillOpacity":1,"type":"rect"}},{"encoding":{"color":{"aggregate":"mean","condition":[{"test":"datum['mean_Score'] < 40","value":"black"},{"test":"datum['mean_Score'] >= 40 && datum['mean_Score'] < 80","value":"white"},{"test":"datum['mean_Score'] >= 60","value":"yellow"},{"test":"true","value":"black"}],"field":"Score","type":"quantitative"},"text":{"aggregate":"mean","field":"Score","format":".1f","type":"quantitative"},"x":{"field":"Task","type":"nominal"},"y":{"field":"Model","type":"nominal"}},"mark":"text"}],"width":250}
Tucan.new()
|> Tucan.annotate(10, 10, "Hello", color: :red, font_size: 20)
|> Tucan.annotate(15, 12, "world...", color: :green, font_weight: :bold)
|> Tucan.Scale.set_xy_domain(8, 17)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"data":{"values":[{"x":10,"y":10}]},"encoding":{"x":{"field":"x","scale":{"domain":[8,17]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[8,17]},"type":"quantitative"}},"mark":{"color":"red","fontSize":20,"text":"Hello","type":"text"}},{"data":{"values":[{"x":15,"y":12}]},"encoding":{"x":{"field":"x","scale":{"domain":[8,17]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[8,17]},"type":"quantitative"}},"mark":{"color":"green","fontWeight":"bold","text":"world...","type":"text"}}]}
Tucan.new()
|> Tucan.circle({3, 2}, 5, line_color: "purple")
|> Tucan.circle({-1, 6}, 2, line_color: "red")
|> Tucan.circle({0, 1}, 4, line_color: "green", stroke_width: 3)
|> Tucan.Scale.set_xy_domain(-4, 8)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"data":{"sequence":{"as":"theta","start":0,"step":0.1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-4,8]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-4,8]},"type":"quantitative"}},"mark":{"color":"purple","fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"},"transform":[{"as":"x","calculate":"3 + cos(datum.theta*PI/180) * 5"},{"as":"y","calculate":"2 + sin(datum.theta*PI/180) * 5"}]},{"data":{"sequence":{"as":"theta","start":0,"step":0.1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-4,8]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-4,8]},"type":"quantitative"}},"mark":{"color":"red","fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"},"transform":[{"as":"x","calculate":"-1 + cos(datum.theta*PI/180) * 2"},{"as":"y","calculate":"6 + sin(datum.theta*PI/180) * 2"}]},{"data":{"sequence":{"as":"theta","start":0,"step":0.1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-4,8]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-4,8]},"type":"quantitative"}},"mark":{"color":"green","fillOpacity":1,"strokeOpacity":1,"strokeWidth":3,"type":"line"},"transform":[{"as":"x","calculate":"0 + cos(datum.theta*PI/180) * 4"},{"as":"y","calculate":"1 + sin(datum.theta*PI/180) * 4"}]}]}

Added plot options

v0.2.0 (2023-09-23)

Added

Tucan.jointplot(
  :penguins,
  "Beak Length (mm)",
  "Beak Depth (mm)",
  marginal: :density,
  color_by: "Species",
  marginal_opts: [fill_opacity: 0.5]
)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","bounds":"flush","data":{"url":"https://raw.githubusercontent.com/vega/vega-datasets/next/data/penguins.json"},"spacing":15,"vconcat":[{"encoding":{"color":{"field":"Species"},"x":{"axis":null,"field":"value","scale":{"zero":false},"type":"quantitative"},"y":{"field":"density","stack":null,"type":"quantitative"}},"height":90,"mark":{"fillOpacity":0.5,"orient":"vertical","type":"area"},"transform":[{"counts":false,"cumulative":false,"density":"Beak Length (mm)","groupby":["Species"],"maxsteps":200,"minsteps":25}]},{"bounds":"flush","hconcat":[{"encoding":{"color":{"field":"Species","type":"nominal"},"x":{"field":"Beak Length (mm)","scale":{"zero":false},"type":"quantitative"},"y":{"field":"Beak Depth (mm)","scale":{"zero":false},"type":"quantitative"}},"height":200,"mark":{"fillOpacity":1,"type":"point"},"width":200},{"encoding":{"color":{"field":"Species"},"x":{"field":"density","stack":null,"type":"quantitative"},"y":{"axis":null,"field":"value","scale":{"zero":false},"type":"quantitative"}},"mark":{"fillOpacity":0.5,"orient":"horizontal","type":"area"},"transform":[{"counts":false,"cumulative":false,"density":"Beak Depth (mm)","groupby":["Species"],"maxsteps":200,"minsteps":25}],"width":90}],"spacing":15}]}
  • Add Tucan.punchcard/5 plot. This is similar to heatmap but the third dimension is encoded by size instead of color.
Tucan.punchcard(:glue, "Task", "Model", "Score")
|> Tucan.color_by("Score", recursive: true, type: :quantitative)
|> Tucan.set_size(250, 250)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","__tucan__":{"multilayer":true},"data":{"url":"https://raw.githubusercontent.com/mwaskom/seaborn-data/master/glue.csv"},"height":250,"layer":[{"encoding":{"color":{"field":"Score","type":"quantitative"},"size":{"aggregate":"mean","field":"Score","type":"quantitative"},"x":{"field":"Task","type":"nominal"},"y":{"field":"Model","type":"nominal"}},"mark":{"fillOpacity":1,"type":"circle"}}],"width":250}
Tucan.heatmap(:glue, "Task", "Model", "Score", annotate: true, text: [format: ".1f"])
|> Tucan.set_size(250, 250)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","__tucan__":{"multilayer":true},"data":{"url":"https://raw.githubusercontent.com/mwaskom/seaborn-data/master/glue.csv"},"height":250,"layer":[{"encoding":{"color":{"aggregate":"mean","field":"Score","type":"quantitative"},"x":{"field":"Task","type":"nominal"},"y":{"field":"Model","type":"nominal"}},"mark":{"fillOpacity":1,"type":"rect"}},{"encoding":{"text":{"aggregate":"mean","field":"Score","format":".1f","type":"quantitative"},"x":{"field":"Task","type":"nominal"},"y":{"field":"Model","type":"nominal"}},"mark":"text"}],"width":250}
Tucan.scatter(:iris, "petal_width", "petal_length", width: 300)
|> Tucan.hruler(3, line_color: "green")
|> Tucan.vruler("petal_width", color_by: "species", stroke_width: 3)
|> Tucan.hruler("petal_length", color_by: "species")
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","data":{"url":"https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csv"},"layer":[{"encoding":{"x":{"field":"petal_width","scale":{"zero":false},"type":"quantitative"},"y":{"field":"petal_length","scale":{"zero":false},"type":"quantitative"}},"mark":{"fillOpacity":1,"type":"point"}},{"encoding":{"y":{"datum":3}},"mark":{"color":"green","strokeWidth":1,"type":"rule"}},{"encoding":{"color":{"field":"species"},"x":{"aggregate":"mean","field":"petal_width","type":"quantitative"}},"mark":{"color":"black","strokeWidth":3,"type":"rule"}},{"encoding":{"color":{"field":"species"},"y":{"aggregate":"mean","field":"petal_length","type":"quantitative"}},"mark":{"color":"black","strokeWidth":1,"type":"rule"}}],"width":300}
Tucan.layers([
  Tucan.scatter(:iris, "petal_width", "petal_length", point_color: "red"),
  Tucan.scatter(:iris, "sepal_width", "sepal_length", point_color: "green")
])
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"data":{"url":"https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csv"},"encoding":{"x":{"field":"petal_width","scale":{"zero":false},"type":"quantitative"},"y":{"field":"petal_length","scale":{"zero":false},"type":"quantitative"}},"mark":{"color":"red","fillOpacity":1,"type":"point"}},{"data":{"url":"https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csv"},"encoding":{"x":{"field":"sepal_width","scale":{"zero":false},"type":"quantitative"},"y":{"field":"sepal_length","scale":{"zero":false},"type":"quantitative"}},"mark":{"color":"green","fillOpacity":1,"type":"point"}}]}

Added plots options

Fixed

  • Support setting :orient in Tucan.density/3.
  • Make size encodings quantitative by default.

Deprecated

v0.1.1 (2023-08-29)

Added

  • Add concat/2, hconcat/2 and vconcat/2 helper concatenation functions.

v0.1.0 (2023-08-28)

Initial release.