How to plot a lilaq contour of a (x,y,z) csv data?

I have a x,y,z csv data file, how to plot contour using lilaq ?
CSV data is:

#H2O/CH4,CO2/CH4,H2/CO
#X,Y,Z
0.5,0.5,1.508930747
0.5,0.6,1.395645167
0.5,0.7,1.302159329
0.5,0.8,1.22307389
0.5,0.9,1.154830727
0.5,1,1.095020315
0.5,1.1,1.041901384
0.5,1.2,0.994213985
0.5,1.3,0.951030085
0.5,1.4,0.911625868
0.5,1.5,0.875443546
0.5,1.6,0.84204167
0.5,1.7,0.811068955
0.5,1.8,0.782228617
0.5,1.9,0.755290078
0.5,2,0.730053235
0.5,2.1,0.706342532
0.5,2.2,0.684025876
0.5,2.3,0.663035659
0.5,2.4,0.643124444
0.5,2.5,0.624287025
0.6,0.5,1.594702485
0.6,0.6,1.473431058
0.6,0.7,1.372937939
0.6,0.8,1.28776104
0.6,0.9,1.214230107
0.6,1,1.149822935
0.6,1.1,1.092684871
0.6,1.2,1.041490486
0.6,1.3,0.995222423
0.6,1.4,0.95308994
0.6,1.5,0.914487982
0.6,1.6,0.87893335
0.6,1.7,0.846028755
0.6,1.8,0.815456034
0.6,1.9,0.786962102
0.6,2,0.760309698
0.6,2.1,0.735316424
0.6,2.2,0.711828569
0.6,2.3,0.689784881
0.6,2.4,0.668892493
0.6,2.5,0.649145524
0.7,0.5,1.674886369
0.7,0.6,1.546848516
0.7,0.7,1.440261306
0.7,0.8,1.349688343
0.7,0.9,1.271412162
0.7,1,1.202828038
0.7,1.1,1.142016246
0.7,1.2,1.087575212
0.7,1.3,1.03842533
0.7,1.4,0.993735034
0.7,1.5,0.952858047
0.7,1.6,0.915257702
0.7,1.7,0.880520892
0.7,1.8,0.848299718
0.7,1.9,0.818300433
0.7,2,0.790282557
0.7,2.1,0.764050645
0.7,2.2,0.739539292
0.7,2.3,0.716357636
0.7,2.4,0.694507118
0.7,2.5,0.673868933
0.8,0.5,1.750571124
0.8,0.6,1.616661697
0.8,0.7,1.504687232
0.8,0.8,1.409281474
0.8,0.9,1.326701714
0.8,1,1.254282483
0.8,1.1,1.19006865
0.8,1.2,1.132606926
0.8,1.3,1.080765943
0.8,1.4,1.033663838
0.8,1.5,0.990618895
0.8,1.6,0.951078526
0.8,1.7,0.914588545
0.8,1.8,0.880774103
0.8,1.9,0.849328143
0.8,2,0.819992834
0.8,2.1,0.792707173
0.8,2.2,0.766960916
0.8,2.3,0.742762839
0.8,2.4,0.719971165
0.8,2.5,0.698465269
0.9,0.5,1.82256167
0.9,0.6,1.683460368
0.9,0.7,1.566683574
0.9,0.8,1.466880367
0.9,0.9,1.380346384
0.9,1,1.304389273
0.9,1.1,1.237012901
0.9,1.2,1.176708249
0.9,1.3,1.122317779
0.9,1.4,1.0729347
0.9,1.5,1.027833295
0.9,1.6,0.986436702
0.9,1.7,0.948257774
0.9,1.8,0.912907951
0.9,1.9,0.880072009
0.9,2,0.849650176
0.9,2.1,0.821026885
0.9,2.2,0.794199487
0.9,2.3,0.769007119
0.9,2.4,0.745295535
0.9,2.5,0.722937842
1,0.5,1.89150863
1,0.6,1.747762544
1,0.7,1.626586748
1,0.8,1.522754324
1,0.9,1.432570291
1,1,1.35331272
1,1.1,1.282957964
1,1.2,1.219978291
1,1.3,1.163179016
1,1.4,1.111620015
1,1.5,1.064549657
1,1.6,1.021370354
1,1.7,0.981568842
1,1.8,0.944738411
1,1.9,0.91054249
1,2,0.878911044
1,2.1,0.849142705
1,2.2,0.821270766
1,2.3,0.795101129
1,2.4,0.770491346
1,2.5,0.747292864
1.1,0.5,1.957917768
1.1,0.6,1.80994013
1.1,0.7,1.684711879
1.1,0.8,1.577152766
1.1,0.9,1.483545648
1.1,1,1.401174141
1.1,1.1,1.328029072
1.1,1.2,1.262504917
1.1,1.3,1.203413092
1.1,1.4,1.149762192
1.1,1.5,1.100824623
1.1,1.6,1.055915287
1.1,1.7,1.01453842
1.1,1.8,0.97628047
1.1,1.9,0.94103244
1.1,2,0.907956906
1.1,2.1,0.877074094
1.1,2.2,0.848173393
1.1,2.3,0.821052379
1.1,2.4,0.795558253
1.1,2.5,0.771537313
1.2,0.5,2.02219799
1.2,0.6,1.87028154
1.2,0.7,1.741314278
1.2,0.8,1.630242169
1.2,0.9,1.533422976
1.2,1,1.448136395
1.2,1.1,1.372309048
1.2,1.2,1.304374161
1.2,1.3,1.243076518
1.2,1.4,1.187451494
1.2,1.5,1.136670875
1.2,1.6,1.090098101
1.2,1.7,1.047207469
1.2,1.8,1.007870485
1.2,1.9,0.971057737
1.2,2,0.936804085
1.2,2.1,0.904832504
1.2,2.2,0.874916613
1.2,2.3,0.846865714
1.2,2.4,0.820502445
1.2,2.5,0.795672154
1.3,0.5,2.084654275
1.3,0.6,1.929059329
1.3,0.7,1.796554915
1.3,0.8,1.682202254
1.3,0.9,1.582339814
1.3,1,1.494250902
1.3,1.1,1.415896007
1.3,1.2,1.345635884
1.3,1.3,1.28224804
1.3,1.4,1.224680809
1.3,1.5,1.172137767
1.3,1.6,1.123960081
1.3,1.7,1.079969715
1.3,1.8,1.038933642
1.3,1.9,1.000869449
1.3,2,0.965459712
1.3,2.1,0.932429812
1.3,2.2,0.901526061
1.3,2.3,0.87255229
1.3,2.4,0.845330135
1.3,2.5,0.819699997
1.4,0.5,2.14557137
1.4,0.6,1.986494798
1.4,0.7,1.850648969
1.4,0.8,1.733150172
1.4,0.9,1.630395385
1.4,1,1.539650261
1.4,1.1,1.458841906
1.4,1.2,1.386376022
1.4,1.3,1.320942871
1.4,1.4,1.261509387
1.4,1.5,1.207259299
1.4,1.6,1.157957342
1.4,1.7,1.112123395
1.4,1.8,1.069758956
1.4,1.9,1.030483725
1.4,2,0.993944637
1.4,2.1,0.959861024
1.4,2.2,0.927992189
1.4,2.3,0.898116672
1.4,2.4,0.87005
1.4,2.5,0.843633246
1.5,0.5,2.205154955
1.5,0.6,2.042765074
1.5,0.7,1.903740244
1.5,0.8,1.783243308
1.5,0.9,1.677694762
1.5,1,1.584393467
1.5,1.1,1.501266724
1.5,1.2,1.426624414
1.5,1.3,1.359201041
1.5,1.4,1.297965626
1.5,1.5,1.242565902
1.5,1.6,1.191271942
1.5,1.7,1.144033323
1.5,1.8,1.100376903
1.5,1.9,1.059908186
1.5,2,1.022260877
1.5,2.1,0.987152907
1.5,2.2,0.954331918
1.5,2.3,0.923565408
1.5,2.4,0.894669388
1.5,2.5,0.867231214
1.6,0.5,2.26359213
1.6,0.6,2.09800615
1.6,0.7,1.955915131
1.6,0.8,1.832541443
1.6,0.9,1.724315437
1.6,1,1.628572058
1.6,1.1,1.543148532
1.6,1.2,1.466415253
1.6,1.3,1.397080865
1.6,1.4,1.334097312
1.6,1.5,1.277112131
1.6,1.6,1.224326983
1.6,1.7,1.175716292
1.6,1.8,1.130804122
1.6,1.9,1.089152423
1.6,2,1.050422844
1.6,2.1,1.014309484
1.6,2.2,0.980543579
1.6,2.3,0.948897475
1.6,2.4,0.918899114
1.6,2.5,0.89095746
1.7,0.5,2.321036706
1.7,0.6,2.152373604
1.7,0.7,2.007319979
1.7,0.8,1.881154375
1.7,0.9,1.770368533
1.7,1,1.67219157
1.7,1.1,1.584556468
1.7,1.2,1.505807539
1.7,1.3,1.434616962
1.7,1.4,1.370532029
1.7,1.5,1.311394636
1.7,1.6,1.257142513
1.7,1.7,1.207203877
1.7,1.8,1.161034059
1.7,1.9,1.118244809
1.7,2,1.078441646
1.7,2.1,1.041330791
1.7,2.2,1.006637249
1.7,2.3,0.973801077
1.7,2.4,0.943305205
1.7,2.5,0.914604604
1.8,0.5,2.377632782
1.8,0.6,2.205953861
1.8,0.7,2.058025726
1.8,0.8,1.929186697
1.8,0.9,1.815841352
1.8,1,1.71534142
1.8,1.1,1.625565261
1.8,1.2,1.544834605
1.8,1.3,1.472520053
1.8,1.4,1.406101419
1.8,1.5,1.345411431
1.8,1.6,1.289754546
1.8,1.7,1.238485086
1.8,1.8,1.191099673
1.8,1.9,1.147169747
1.8,2,1.106324852
1.8,2.1,1.068229206
1.8,2.2,1.03262515
1.8,2.3,0.998909872
1.8,2.4,0.967615669
1.8,2.5,0.9381655
1.9,0.5,2.433493825
1.9,0.6,2.258905636
1.9,0.7,2.108135646
1.9,0.8,1.976613898
1.9,0.9,1.860834551
1.9,1,1.758060736
1.9,1.1,1.666175307
1.9,1.2,1.584317292
1.9,1.3,1.509477296
1.9,1.4,1.441404922
1.9,1.5,1.379210633
1.9,1.6,1.322145335
1.9,1.7,1.269582794
1.9,1.8,1.22099693
1.9,1.9,1.175959859
1.9,2,1.1340755
1.9,2.1,1.095019115
1.9,2.2,1.058097725
1.9,2.3,1.023926107
1.9,2.4,0.991838585
1.9,2.5,0.961648288
2,0.5,2.48872862
2,0.6,2.311212135
2,0.7,2.157680284
2,0.8,2.023586678
2,0.9,1.905385051
2,1,1.800386265
2,1.1,1.707354106
2,1.2,1.622743784
2,1.3,1.546147703
2,1.4,1.476472415
2,1.5,1.412792524
2,1.6,1.354347433
2,1.7,1.300514773
2,1.8,1.250750715
2,1.9,1.204608673
2,2,1.161697591
2,2.1,1.121220486
2,2.2,1.083861162
2,2.3,1.048849066
2,2.4,1.015983626
2,2.5,0.985057365
2.1,0.5,2.54336522
2.1,0.6,2.362964764
2.1,0.7,2.206723999
2.1,0.8,2.070078773
2.1,0.9,1.94954062
2.1,1,1.843359005
2.1,1.1,1.747354929
2.1,1.2,1.660885522
2.1,1.3,1.582586083
2.1,1.4,1.511322733
2.1,1.5,1.446180657
2.1,1.6,1.386381666
2.1,1.7,1.331286276
2.1,1.8,1.280360429
2.1,1.9,1.23313363
2.1,2,1.18868882
2.1,2.1,1.147770964
2.1,2.2,1.109520737
2.1,2.3,1.073690193
2.1,2.4,1.040040846
2.1,2.5,1.008398842
2.2,0.5,2.5975005
2.2,0.6,2.414247598
2.2,0.7,2.255338158
2.2,0.8,2.117397478
2.2,0.9,1.994444174
2.2,1,1.885058545
2.2,1.1,1.787076398
2.2,1.2,1.698775104
2.2,1.3,1.618786417
2.2,1.4,1.545968673
2.2,1.5,1.479379047
2.2,1.6,1.418249039
2.2,1.7,1.36191367
2.2,1.8,1.309833551
2.2,1.9,1.260943386
2.2,2,1.21606934
2.2,2.1,1.17421196
2.2,2.2,1.13510004
2.2,2.3,1.098445315
2.2,2.4,1.064033277
2.2,2.5,1.031664158
2.3,0.5,2.651175772
2.3,0.6,2.465127113
2.3,0.7,2.304897286
2.3,0.8,2.163213814
2.3,0.9,2.037978628
2.3,1,1.926470473
2.3,1.1,1.826516881
2.3,1.2,1.736424391
2.3,1.3,1.654781439
2.3,1.4,1.580412856
2.3,1.5,1.512402819
2.3,1.6,1.449950803
2.3,1.7,1.392407045
2.3,1.8,1.338522849
2.3,1.9,1.28920745
2.3,2,1.243341623
2.3,2.1,1.200569963
2.3,2.2,1.160584961
2.3,2.3,1.123128648
2.3,2.4,1.08795296
2.3,2.5,1.05487206
2.4,0.5,2.704480771
2.4,0.6,2.5171025
2.4,0.7,2.352828284
2.4,0.8,2.208714861
2.4,0.9,2.081207303
2.4,1,1.967610532
2.4,1.1,1.865738089
2.4,1.2,1.773868163
2.4,1.3,1.690572079
2.4,1.4,1.61469129
2.4,1.5,1.545271589
2.4,1.6,1.481520715
2.4,1.7,1.422019799
2.4,1.8,1.367721882
2.4,1.9,1.31735997
2.4,2,1.270523497
2.4,2.1,1.226837374
2.4,2.2,1.185996389
2.4,2.3,1.147732177
2.4,2.4,1.111809809
2.4,2.5,1.078010061
2.5,0.5,2.759061428
2.5,0.6,2.567322854
2.5,0.7,2.400466299
2.5,0.8,2.253893713
2.5,0.9,2.12415448
2.5,1,2.008500605
2.5,1.1,1.904730683
2.5,1.2,1.811090037
2.5,1.3,1.726178067
2.5,1.4,1.648808032
2.5,1.5,1.578000122
2.5,1.6,1.512126584
2.5,1.7,1.452221157
2.5,1.8,1.396809372
2.5,1.9,1.345413508
2.5,2,1.297604748
2.5,2.1,1.253011347
2.5,2.2,1.21132766
2.5,2.3,1.172266348
2.5,2.4,1.135590896
2.5,2.5,1.101094413

The latex contour plot:

Hi, you can find some documentation for contour plots in lilaq here. To read the data file, lilaq’s load-txt function seems appropriate. As the contour function expects the z values to be given as a 2D array, you need to restructure the data accordingly:

#import "@preview/lilaq:0.3.0" as lq
#import "@preview/typsium:0.2.0": ce

#{
  let (x, y, z) = lq.load-txt(read("data.csv"))
  
  let x = x.dedup() // Unique x values
  let y = y.dedup() // Unique y values

  // Group z values into chunks, so that each chunk
  // has exactly one entry for each unique y value.
  // Then transpose the 2D-array to make it Y×X.
  let z = array.zip(..z.chunks(y.len()))

  let contour = lq.contour(x, y, z, map: color.map.turbo)

  lq.diagram(
    xlabel: [#ce("H2O / CH4") / mol/mol],
    ylabel: [#ce("CO2 / CH4") / mol/mol],
    contour
  )
  
  lq.colorbar(contour) // (colorbar is experimental)
}
Output

I don’t know how to set the color of the axis labels and ticks, maybe someone else can chime in for that. Also, I’m not sure if labels on the contour lines are possible at the moment.

3 Likes

Since the colorbar is not modifiable, to get the 0.2 step it needs to be copied. Though I don’t know how to place tick labels centered and not under the ticks.

#import "@preview/lilaq:0.3.0" as lq
#import "@preview/typsium:0.2.0": ce

#let data = ```csv
#H2O/CH4,CO2/CH4,H2/CO
#X,Y,Z
0.5,0.5,1.508930747
0.5,0.6,1.395645167
0.5,0.7,1.302159329
0.5,0.8,1.22307389
0.5,0.9,1.154830727
0.5,1,1.095020315
0.5,1.1,1.041901384
0.5,1.2,0.994213985
0.5,1.3,0.951030085
0.5,1.4,0.911625868
0.5,1.5,0.875443546
0.5,1.6,0.84204167
0.5,1.7,0.811068955
0.5,1.8,0.782228617
0.5,1.9,0.755290078
0.5,2,0.730053235
0.5,2.1,0.706342532
0.5,2.2,0.684025876
0.5,2.3,0.663035659
0.5,2.4,0.643124444
0.5,2.5,0.624287025
0.6,0.5,1.594702485
0.6,0.6,1.473431058
0.6,0.7,1.372937939
0.6,0.8,1.28776104
0.6,0.9,1.214230107
0.6,1,1.149822935
0.6,1.1,1.092684871
0.6,1.2,1.041490486
0.6,1.3,0.995222423
0.6,1.4,0.95308994
0.6,1.5,0.914487982
0.6,1.6,0.87893335
0.6,1.7,0.846028755
0.6,1.8,0.815456034
0.6,1.9,0.786962102
0.6,2,0.760309698
0.6,2.1,0.735316424
0.6,2.2,0.711828569
0.6,2.3,0.689784881
0.6,2.4,0.668892493
0.6,2.5,0.649145524
0.7,0.5,1.674886369
0.7,0.6,1.546848516
0.7,0.7,1.440261306
0.7,0.8,1.349688343
0.7,0.9,1.271412162
0.7,1,1.202828038
0.7,1.1,1.142016246
0.7,1.2,1.087575212
0.7,1.3,1.03842533
0.7,1.4,0.993735034
0.7,1.5,0.952858047
0.7,1.6,0.915257702
0.7,1.7,0.880520892
0.7,1.8,0.848299718
0.7,1.9,0.818300433
0.7,2,0.790282557
0.7,2.1,0.764050645
0.7,2.2,0.739539292
0.7,2.3,0.716357636
0.7,2.4,0.694507118
0.7,2.5,0.673868933
0.8,0.5,1.750571124
0.8,0.6,1.616661697
0.8,0.7,1.504687232
0.8,0.8,1.409281474
0.8,0.9,1.326701714
0.8,1,1.254282483
0.8,1.1,1.19006865
0.8,1.2,1.132606926
0.8,1.3,1.080765943
0.8,1.4,1.033663838
0.8,1.5,0.990618895
0.8,1.6,0.951078526
0.8,1.7,0.914588545
0.8,1.8,0.880774103
0.8,1.9,0.849328143
0.8,2,0.819992834
0.8,2.1,0.792707173
0.8,2.2,0.766960916
0.8,2.3,0.742762839
0.8,2.4,0.719971165
0.8,2.5,0.698465269
0.9,0.5,1.82256167
0.9,0.6,1.683460368
0.9,0.7,1.566683574
0.9,0.8,1.466880367
0.9,0.9,1.380346384
0.9,1,1.304389273
0.9,1.1,1.237012901
0.9,1.2,1.176708249
0.9,1.3,1.122317779
0.9,1.4,1.0729347
0.9,1.5,1.027833295
0.9,1.6,0.986436702
0.9,1.7,0.948257774
0.9,1.8,0.912907951
0.9,1.9,0.880072009
0.9,2,0.849650176
0.9,2.1,0.821026885
0.9,2.2,0.794199487
0.9,2.3,0.769007119
0.9,2.4,0.745295535
0.9,2.5,0.722937842
1,0.5,1.89150863
1,0.6,1.747762544
1,0.7,1.626586748
1,0.8,1.522754324
1,0.9,1.432570291
1,1,1.35331272
1,1.1,1.282957964
1,1.2,1.219978291
1,1.3,1.163179016
1,1.4,1.111620015
1,1.5,1.064549657
1,1.6,1.021370354
1,1.7,0.981568842
1,1.8,0.944738411
1,1.9,0.91054249
1,2,0.878911044
1,2.1,0.849142705
1,2.2,0.821270766
1,2.3,0.795101129
1,2.4,0.770491346
1,2.5,0.747292864
1.1,0.5,1.957917768
1.1,0.6,1.80994013
1.1,0.7,1.684711879
1.1,0.8,1.577152766
1.1,0.9,1.483545648
1.1,1,1.401174141
1.1,1.1,1.328029072
1.1,1.2,1.262504917
1.1,1.3,1.203413092
1.1,1.4,1.149762192
1.1,1.5,1.100824623
1.1,1.6,1.055915287
1.1,1.7,1.01453842
1.1,1.8,0.97628047
1.1,1.9,0.94103244
1.1,2,0.907956906
1.1,2.1,0.877074094
1.1,2.2,0.848173393
1.1,2.3,0.821052379
1.1,2.4,0.795558253
1.1,2.5,0.771537313
1.2,0.5,2.02219799
1.2,0.6,1.87028154
1.2,0.7,1.741314278
1.2,0.8,1.630242169
1.2,0.9,1.533422976
1.2,1,1.448136395
1.2,1.1,1.372309048
1.2,1.2,1.304374161
1.2,1.3,1.243076518
1.2,1.4,1.187451494
1.2,1.5,1.136670875
1.2,1.6,1.090098101
1.2,1.7,1.047207469
1.2,1.8,1.007870485
1.2,1.9,0.971057737
1.2,2,0.936804085
1.2,2.1,0.904832504
1.2,2.2,0.874916613
1.2,2.3,0.846865714
1.2,2.4,0.820502445
1.2,2.5,0.795672154
1.3,0.5,2.084654275
1.3,0.6,1.929059329
1.3,0.7,1.796554915
1.3,0.8,1.682202254
1.3,0.9,1.582339814
1.3,1,1.494250902
1.3,1.1,1.415896007
1.3,1.2,1.345635884
1.3,1.3,1.28224804
1.3,1.4,1.224680809
1.3,1.5,1.172137767
1.3,1.6,1.123960081
1.3,1.7,1.079969715
1.3,1.8,1.038933642
1.3,1.9,1.000869449
1.3,2,0.965459712
1.3,2.1,0.932429812
1.3,2.2,0.901526061
1.3,2.3,0.87255229
1.3,2.4,0.845330135
1.3,2.5,0.819699997
1.4,0.5,2.14557137
1.4,0.6,1.986494798
1.4,0.7,1.850648969
1.4,0.8,1.733150172
1.4,0.9,1.630395385
1.4,1,1.539650261
1.4,1.1,1.458841906
1.4,1.2,1.386376022
1.4,1.3,1.320942871
1.4,1.4,1.261509387
1.4,1.5,1.207259299
1.4,1.6,1.157957342
1.4,1.7,1.112123395
1.4,1.8,1.069758956
1.4,1.9,1.030483725
1.4,2,0.993944637
1.4,2.1,0.959861024
1.4,2.2,0.927992189
1.4,2.3,0.898116672
1.4,2.4,0.87005
1.4,2.5,0.843633246
1.5,0.5,2.205154955
1.5,0.6,2.042765074
1.5,0.7,1.903740244
1.5,0.8,1.783243308
1.5,0.9,1.677694762
1.5,1,1.584393467
1.5,1.1,1.501266724
1.5,1.2,1.426624414
1.5,1.3,1.359201041
1.5,1.4,1.297965626
1.5,1.5,1.242565902
1.5,1.6,1.191271942
1.5,1.7,1.144033323
1.5,1.8,1.100376903
1.5,1.9,1.059908186
1.5,2,1.022260877
1.5,2.1,0.987152907
1.5,2.2,0.954331918
1.5,2.3,0.923565408
1.5,2.4,0.894669388
1.5,2.5,0.867231214
1.6,0.5,2.26359213
1.6,0.6,2.09800615
1.6,0.7,1.955915131
1.6,0.8,1.832541443
1.6,0.9,1.724315437
1.6,1,1.628572058
1.6,1.1,1.543148532
1.6,1.2,1.466415253
1.6,1.3,1.397080865
1.6,1.4,1.334097312
1.6,1.5,1.277112131
1.6,1.6,1.224326983
1.6,1.7,1.175716292
1.6,1.8,1.130804122
1.6,1.9,1.089152423
1.6,2,1.050422844
1.6,2.1,1.014309484
1.6,2.2,0.980543579
1.6,2.3,0.948897475
1.6,2.4,0.918899114
1.6,2.5,0.89095746
1.7,0.5,2.321036706
1.7,0.6,2.152373604
1.7,0.7,2.007319979
1.7,0.8,1.881154375
1.7,0.9,1.770368533
1.7,1,1.67219157
1.7,1.1,1.584556468
1.7,1.2,1.505807539
1.7,1.3,1.434616962
1.7,1.4,1.370532029
1.7,1.5,1.311394636
1.7,1.6,1.257142513
1.7,1.7,1.207203877
1.7,1.8,1.161034059
1.7,1.9,1.118244809
1.7,2,1.078441646
1.7,2.1,1.041330791
1.7,2.2,1.006637249
1.7,2.3,0.973801077
1.7,2.4,0.943305205
1.7,2.5,0.914604604
1.8,0.5,2.377632782
1.8,0.6,2.205953861
1.8,0.7,2.058025726
1.8,0.8,1.929186697
1.8,0.9,1.815841352
1.8,1,1.71534142
1.8,1.1,1.625565261
1.8,1.2,1.544834605
1.8,1.3,1.472520053
1.8,1.4,1.406101419
1.8,1.5,1.345411431
1.8,1.6,1.289754546
1.8,1.7,1.238485086
1.8,1.8,1.191099673
1.8,1.9,1.147169747
1.8,2,1.106324852
1.8,2.1,1.068229206
1.8,2.2,1.03262515
1.8,2.3,0.998909872
1.8,2.4,0.967615669
1.8,2.5,0.9381655
1.9,0.5,2.433493825
1.9,0.6,2.258905636
1.9,0.7,2.108135646
1.9,0.8,1.976613898
1.9,0.9,1.860834551
1.9,1,1.758060736
1.9,1.1,1.666175307
1.9,1.2,1.584317292
1.9,1.3,1.509477296
1.9,1.4,1.441404922
1.9,1.5,1.379210633
1.9,1.6,1.322145335
1.9,1.7,1.269582794
1.9,1.8,1.22099693
1.9,1.9,1.175959859
1.9,2,1.1340755
1.9,2.1,1.095019115
1.9,2.2,1.058097725
1.9,2.3,1.023926107
1.9,2.4,0.991838585
1.9,2.5,0.961648288
2,0.5,2.48872862
2,0.6,2.311212135
2,0.7,2.157680284
2,0.8,2.023586678
2,0.9,1.905385051
2,1,1.800386265
2,1.1,1.707354106
2,1.2,1.622743784
2,1.3,1.546147703
2,1.4,1.476472415
2,1.5,1.412792524
2,1.6,1.354347433
2,1.7,1.300514773
2,1.8,1.250750715
2,1.9,1.204608673
2,2,1.161697591
2,2.1,1.121220486
2,2.2,1.083861162
2,2.3,1.048849066
2,2.4,1.015983626
2,2.5,0.985057365
2.1,0.5,2.54336522
2.1,0.6,2.362964764
2.1,0.7,2.206723999
2.1,0.8,2.070078773
2.1,0.9,1.94954062
2.1,1,1.843359005
2.1,1.1,1.747354929
2.1,1.2,1.660885522
2.1,1.3,1.582586083
2.1,1.4,1.511322733
2.1,1.5,1.446180657
2.1,1.6,1.386381666
2.1,1.7,1.331286276
2.1,1.8,1.280360429
2.1,1.9,1.23313363
2.1,2,1.18868882
2.1,2.1,1.147770964
2.1,2.2,1.109520737
2.1,2.3,1.073690193
2.1,2.4,1.040040846
2.1,2.5,1.008398842
2.2,0.5,2.5975005
2.2,0.6,2.414247598
2.2,0.7,2.255338158
2.2,0.8,2.117397478
2.2,0.9,1.994444174
2.2,1,1.885058545
2.2,1.1,1.787076398
2.2,1.2,1.698775104
2.2,1.3,1.618786417
2.2,1.4,1.545968673
2.2,1.5,1.479379047
2.2,1.6,1.418249039
2.2,1.7,1.36191367
2.2,1.8,1.309833551
2.2,1.9,1.260943386
2.2,2,1.21606934
2.2,2.1,1.17421196
2.2,2.2,1.13510004
2.2,2.3,1.098445315
2.2,2.4,1.064033277
2.2,2.5,1.031664158
2.3,0.5,2.651175772
2.3,0.6,2.465127113
2.3,0.7,2.304897286
2.3,0.8,2.163213814
2.3,0.9,2.037978628
2.3,1,1.926470473
2.3,1.1,1.826516881
2.3,1.2,1.736424391
2.3,1.3,1.654781439
2.3,1.4,1.580412856
2.3,1.5,1.512402819
2.3,1.6,1.449950803
2.3,1.7,1.392407045
2.3,1.8,1.338522849
2.3,1.9,1.28920745
2.3,2,1.243341623
2.3,2.1,1.200569963
2.3,2.2,1.160584961
2.3,2.3,1.123128648
2.3,2.4,1.08795296
2.3,2.5,1.05487206
2.4,0.5,2.704480771
2.4,0.6,2.5171025
2.4,0.7,2.352828284
2.4,0.8,2.208714861
2.4,0.9,2.081207303
2.4,1,1.967610532
2.4,1.1,1.865738089
2.4,1.2,1.773868163
2.4,1.3,1.690572079
2.4,1.4,1.61469129
2.4,1.5,1.545271589
2.4,1.6,1.481520715
2.4,1.7,1.422019799
2.4,1.8,1.367721882
2.4,1.9,1.31735997
2.4,2,1.270523497
2.4,2.1,1.226837374
2.4,2.2,1.185996389
2.4,2.3,1.147732177
2.4,2.4,1.111809809
2.4,2.5,1.078010061
2.5,0.5,2.759061428
2.5,0.6,2.567322854
2.5,0.7,2.400466299
2.5,0.8,2.253893713
2.5,0.9,2.12415448
2.5,1,2.008500605
2.5,1.1,1.904730683
2.5,1.2,1.811090037
2.5,1.3,1.726178067
2.5,1.4,1.648808032
2.5,1.5,1.578000122
2.5,1.6,1.512126584
2.5,1.7,1.452221157
2.5,1.8,1.396809372
2.5,1.9,1.345413508
2.5,2,1.297604748
2.5,2.1,1.253011347
2.5,2.2,1.21132766
2.5,2.3,1.172266348
2.5,2.4,1.135590896
2.5,2.5,1.101094413
```.text


#let (x, y, z) = lq.load-txt(data)

#let x = x.dedup() // Unique x values
#let y = y.dedup() // Unique y values

// Group z values into chunks, so that each chunk
// has exactly one entry for each unique y value.
// Then transpose the 2D-array to make it Y×X.
#let z = array.zip(..z.chunks(y.len()))

#let contour = lq.contour(x, y, z, map: color.map.turbo)

#let colorbar(plot) = {
  let cinfo = plot.cinfo
  lq.diagram(
    width: 0.3cm,
    xaxis: (ticks: none),
    yaxis: (tick-distance: 0.2, position: right, mirror: (:)),
    ylim: (cinfo.min, cinfo.max),
    grid: none,
    lq.rect(0%, 0%, width: 100%, height: 100%, fill: gradient.linear(
      ..cinfo.colormap.stops(),
      angle: -90deg,
    )),
  )
}

#lq.diagram(
  xlabel: [#ce("H2O / CH4") / mol/mol],
  ylabel: [#ce("CO2 / CH4") / mol/mol],
  contour,
)
#colorbar(contour)

For making helper function with the continuous legend see Is there a cleaner way to draw a heatmap using Lilaq? - #2 by Andrew.

1 Like
  • The misaligned ticks in the colorbar are a bug. They will hopefully be fixed in the next version but it’s a fundamental thing and there is no workaround.
  • Colorbars will soon become very powerful. I haven’t quite decided on the final API and how they integrate with diagrams (suggestions and feedback welcome).
  • Tick labels can easily be colored through show lq.selector(lq.tick-label): set text(red). Doing this separately for x- and y-axes will be possible with the next version because the new version of the elembic package will feature selective show rules.
2 Likes