Contour plot - how to replicate matplotlib contourf

Hi All,
I have been using matplotlib to generate contour plots with the following command:

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
cax = ax.contourf(x, y, z, 50)
cbar = fig.colorbar(cax)

which produces the following plot:
Capture

Matplotlib takes into account that y’s is varying across x which intentionally produces blank areas (is what I want :slightly_smiling_face:).
I have tried to convert this plotting approach to plotly by:

import plotly.tools as tls
plotly_fig = tls.mpl_to_plotly(fig)

but it fails

I would prefer to build the plot directly with plotly/python e.g. like:

import plotly.graph_objects as go
fig = go.Figure(data =
go.Contour(
x =x,
y=y,
z= z
))
fig.show()

but, it is not producing a plot like with matplotlib.

Any help/guidance on how to get a similar plot via plotly as with matplotlib is greatly appreciated.

thanks

data example arrays are below:

x =
[[864 864 864 864 864 864 864 864 864 864 864 864 864 864 864 864 864 864
864 864]
[865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865 865
865 865]
[866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866 866
866 866]
[867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867 867
867 867]
[868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868 868
868 868]
[869 869 869 869 869 869 869 869 869 869 869 869 869 869 869 869 869 869
869 869]
[870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870 870
870 870]
[871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871 871
871 871]
[872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872
872 872]
[873 873 873 873 873 873 873 873 873 873 873 873 873 873 873 873 873 873
873 873]
[874 874 874 874 874 874 874 874 874 874 874 874 874 874 874 874 874 874
874 874]
[875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875
875 875]
[876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876 876
876 876]
[877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877 877
877 877]
[878 878 878 878 878 878 878 878 878 878 878 878 878 878 878 878 878 878
878 878]
[879 879 879 879 879 879 879 879 879 879 879 879 879 879 879 879 879 879
879 879]
[880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880
880 880]
[881 881 881 881 881 881 881 881 881 881 881 881 881 881 881 881 881 881
881 881]
[882 882 882 882 882 882 882 882 882 882 882 882 882 882 882 882 882 882
882 882]
[883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883 883
883 883]
[884 884 884 884 884 884 884 884 884 884 884 884 884 884 884 884 884 884
884 884]
[885 885 885 885 885 885 885 885 885 885 885 885 885 885 885 885 885 885
885 885]
[886 886 886 886 886 886 886 886 886 886 886 886 886 886 886 886 886 886
886 886]
[887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887 887
887 887]
[888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888
888 888]
[889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889
889 889]
[890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890 890
890 890]
[891 891 891 891 891 891 891 891 891 891 891 891 891 891 891 891 891 891
891 891]
[892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892 892
892 892]
[893 893 893 893 893 893 893 893 893 893 893 893 893 893 893 893 893 893
893 893]
[894 894 894 894 894 894 894 894 894 894 894 894 894 894 894 894 894 894
894 894]
[895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895 895
895 895]
[896 896 896 896 896 896 896 896 896 896 896 896 896 896 896 896 896 896
896 896]
[897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897 897
897 897]
[898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898 898
898 898]]
y=
[[-3.9423025 -3.8224788 -3.6936152 -3.5553672 -3.407439 -3.249595
-3.081672 -2.903593 -2.7153785 -2.5171573 -2.3091784 -2.0918162
-1.8655784 -1.631106 -1.3891723 -1.1406771 -0.8866364 -0.6281682
-0.3664745 -0.1028197 ]
[-3.9423907 -3.8227503 -3.6940837 -3.5560474 -3.4083452 -3.2507424
-3.0830765 -2.9052699 -2.717343 -2.5194252 -2.311764 -2.0947344
-1.8688426 -1.6347288 -1.393165 -1.1450499 -0.89139766 -0.6333248
-0.37203127 -0.10877967]
[-3.942479 -3.8230217 -3.6945524 -3.5567274 -3.4092515 -3.25189
-3.0844808 -2.9069464 -2.7193077 -2.5216928 -2.31435 -2.0976527
-1.8721068 -1.6383516 -1.3971578 -1.1494226 -0.89615893 -0.6384813
-0.37758803 -0.11473963]
[-3.942567 -3.8232932 -3.695021 -3.5574074 -3.4101577 -3.2530377
-3.085885 -2.9086232 -2.7212722 -2.5239606 -2.3169358 -2.100571
-1.875371 -1.6419742 -1.4011506 -1.1537954 -0.9009202 -0.6436379
-0.38314477 -0.12069961]
[-3.9426553 -3.8235648 -3.6954894 -3.5580873 -3.411064 -3.2541852
-3.0872896 -2.9103 -2.7232368 -2.5262282 -2.3195214 -2.1034892
-1.8786352 -1.645597 -1.4051433 -1.1581682 -0.9056815 -0.6487944
-0.38870153 -0.12665957]
[-3.9427435 -3.823836 -3.695958 -3.5587673 -3.4119701 -3.255333
-3.0886939 -2.9119768 -2.7252014 -2.528496 -2.3221073 -2.1064072
-1.8818994 -1.6492198 -1.409136 -1.1625409 -0.91044277 -0.653951
-0.3942583 -0.13261954]
[-3.9428318 -3.8241076 -3.6964266 -3.5594473 -3.4128764 -3.2564805
-3.0900984 -2.9136534 -2.727166 -2.5307636 -2.324693 -2.1093254
-1.8851635 -1.6528425 -1.4131287 -1.1669137 -0.91520405 -0.6591075
-0.39981505 -0.1385795 ]
[-3.94292 -3.8243792 -3.6968951 -3.5601273 -3.4137826 -3.257628
-3.0915027 -2.9153302 -2.7291305 -2.5330315 -2.3272789 -2.1122437
-1.8884277 -1.6564653 -1.4171215 -1.1712865 -0.9199653 -0.6642641
-0.40537181 -0.14453948]
[-3.9430084 -3.8246505 -3.6973636 -3.5608072 -3.4146888 -3.2587757
-3.0929072 -2.917007 -2.731095 -2.535299 -2.3298645 -2.115162
-1.8916918 -1.6600881 -1.4211143 -1.1756593 -0.9247266 -0.66942066
-0.41092858 -0.15049945]
[-3.9430966 -3.824922 -3.6978323 -3.5614872 -3.4155948 -3.2599232
-3.0943115 -2.9186838 -2.7330596 -2.537567 -2.3324504 -2.11808
-1.894956 -1.6637108 -1.425107 -1.180032 -0.9294879 -0.6745772
-0.41648534 -0.15645942]
[-3.9431849 -3.8251936 -3.6983008 -3.5621672 -3.416501 -3.2610707
-3.095716 -2.9203603 -2.7350242 -2.5398345 -2.335036 -2.1209981
-1.8982202 -1.6673336 -1.4290998 -1.1844049 -0.93424916 -0.67973375
-0.4220421 -0.16241938]
[-3.943273 -3.8254652 -3.6987693 -3.5628471 -3.4174073 -3.2622185
-3.0971203 -2.9220371 -2.7369888 -2.5421023 -2.337622 -2.1239164
-1.9014844 -1.6709563 -1.4330925 -1.1887776 -0.93901044 -0.6848903
-0.42759886 -0.16837935]
[-3.9433613 -3.8257365 -3.6992378 -3.563527 -3.4183135 -3.263366
-3.0985248 -2.923714 -2.7389534 -2.54437 -2.3402076 -2.1268346
-1.9047486 -1.674579 -1.4370853 -1.1931504 -0.9437717 -0.69004685
-0.43315563 -0.17433932]
[-3.9434516 -3.8260145 -3.6997175 -3.564223 -3.4192412 -3.2645407
-3.0999622 -2.9254303 -2.7409642 -2.5466912 -2.3428545 -2.1298215
-1.9080898 -1.6782873 -1.4411721 -1.1976262 -0.9486453 -0.695325
-0.43884346 -0.18043986]
[-3.9435565 -3.826337 -3.7002745 -3.5650313 -3.4203184 -3.265905
-3.1016316 -2.9274232 -2.7432995 -2.5493867 -2.3459282 -2.1332905
-1.9119699 -1.6825936 -1.4459183 -1.2028241 -0.954305 -0.7014546
-0.44544876 -0.18752448]
[-3.9436615 -3.82666 -3.7008314 -3.5658398 -3.4213955 -3.267269
-3.103301 -2.9294164 -2.7456348 -2.5520825 -2.349002 -2.1367593
-1.91585 -1.6869 -1.4506645 -1.2080221 -0.95996475 -0.7075842
-0.45205408 -0.19460909]
[-3.9437664 -3.8269825 -3.7013884 -3.566648 -3.4224727 -3.2686331
-3.1049705 -2.9314096 -2.74797 -2.554778 -2.3520756 -2.140228
-1.9197301 -1.6912063 -1.4554107 -1.21322 -0.96562445 -0.71371377
-0.4586594 -0.2016937 ]
[-3.943871 -3.8273053 -3.7019453 -3.5674562 -3.42355 -3.2699974
-3.1066399 -2.9334028 -2.7503054 -2.5574737 -2.3551493 -2.143697
-1.9236102 -1.6955128 -1.4601569 -1.2184179 -0.9712842 -0.7198434
-0.46526474 -0.2087783 ]
[-3.943976 -3.8276281 -3.7025023 -3.5682645 -3.424627 -3.2713614
-3.1083093 -2.935396 -2.7526407 -2.5601695 -2.358223 -2.1471658
-1.9274904 -1.6998191 -1.464903 -1.2236158 -0.9769439 -0.72597295
-0.47187003 -0.21586291]
[-3.9440808 -3.8279507 -3.7030594 -3.5690727 -3.4257042 -3.2727256
-3.1099787 -2.937389 -2.754976 -2.562865 -2.3612967 -2.1506348
-1.9313705 -1.7041255 -1.4696492 -1.2288138 -0.98260367 -0.7321026
-0.47847536 -0.22294754]
[-3.9441857 -3.8282735 -3.7036164 -3.5698812 -3.4267817 -3.2740898
-3.111648 -2.939382 -2.7573113 -2.5655606 -2.3643703 -2.1541035
-1.9352506 -1.7084318 -1.4743954 -1.2340117 -0.98826337 -0.73823214
-0.4850807 -0.23003215]
[-3.9442906 -3.828596 -3.7041733 -3.5706894 -3.4278588 -3.2754538
-3.1133175 -2.9413753 -2.7596467 -2.5682561 -2.367444 -2.1575725
-1.9391308 -1.7127383 -1.4791416 -1.2392095 -0.99392307 -0.74436176
-0.491686 -0.23711675]
[-3.9443955 -3.828919 -3.7047303 -3.5714977 -3.428936 -3.276818
-3.114987 -2.9433684 -2.7619817 -2.570952 -2.3705177 -2.1610413
-1.9430108 -1.7170446 -1.4838878 -1.2444074 -0.9995828 -0.7504913
-0.4982913 -0.24420136]
[-3.9445004 -3.8292415 -3.7052872 -3.572306 -3.4300132 -3.2781823
-3.1166563 -2.9453616 -2.764317 -2.5736475 -2.3735917 -2.16451
-1.946891 -1.7213509 -1.4886339 -1.2496053 -1.0052426 -0.75662094
-0.50489664 -0.25128597]
[-3.9446054 -3.8295643 -3.7058442 -3.5731144 -3.4310904 -3.2795463
-3.118326 -2.9473548 -2.7666523 -2.576343 -2.3766654 -2.167979
-1.9507711 -1.7256573 -1.4933801 -1.2548033 -1.0109023 -0.7627505
-0.51150197 -0.25837058]
[-3.9447103 -3.829887 -3.706401 -3.5739226 -3.4321675 -3.2809105
-3.1199954 -2.9493477 -2.7689877 -2.5790389 -2.379739 -2.1714478
-1.9546512 -1.7299637 -1.4981263 -1.2600012 -1.016562 -0.76888007
-0.5181073 -0.2654552 ]
[-3.9448152 -3.8302097 -3.706958 -3.5747309 -3.4332447 -3.2822747
-3.1216648 -2.951341 -2.771323 -2.5817344 -2.3828127 -2.1749167
-1.9585314 -1.7342701 -1.5028725 -1.2651991 -1.0222217 -0.7750097
-0.52471256 -0.2725398 ]
[-3.94492 -3.8305323 -3.707515 -3.575539 -3.434322 -3.2836387
-3.1233342 -2.953334 -2.7736583 -2.58443 -2.3858864 -2.1783855
-1.9624115 -1.7385764 -1.5076187 -1.270397 -1.0278814 -0.78113925
-0.5313179 -0.27962443]
[-3.9450207 -3.8308418 -3.7080493 -3.5763142 -3.435355 -3.284947
-3.124935 -2.9552453 -2.7758975 -2.587015 -2.3888338 -2.181712
-1.9661322 -1.7427058 -1.5121697 -1.2753813 -1.0333086 -0.787017
-0.5376518 -0.28641787]
[-3.9450855 -3.8310413 -3.7083936 -3.576814 -3.4360209 -3.2857902
-3.125967 -2.9564774 -2.7773414 -2.5886815 -2.390734 -2.1838562
-1.9685309 -1.745368 -1.5151039 -1.2785947 -1.0368075 -0.79080635
-0.54173523 -0.29079765]
[-3.9451504 -3.831241 -3.7087379 -3.5773137 -3.4366868 -3.2866335
-3.126999 -2.9577098 -2.778785 -2.5903478 -2.3926342 -2.1860008
-1.9709296 -1.7480303 -1.518038 -1.2818081 -1.0403063 -0.7945957
-0.54581875 -0.29517743]
[-3.9452152 -3.8314404 -3.7090821 -3.5778134 -3.4373527 -3.2874768
-3.128031 -2.958942 -2.7802286 -2.5920143 -2.3945343 -2.1881452
-1.9733284 -1.7506925 -1.5209721 -1.2850215 -1.0438052 -0.7983851
-0.5499022 -0.29955724]
[-3.9452798 -3.83164 -3.7094264 -3.5783129 -3.4380188 -3.28832
-3.1290631 -2.960174 -2.7816725 -2.5936809 -2.3964345 -2.1902897
-1.9757271 -1.7533548 -1.5239062 -1.288235 -1.0473042 -0.80217445
-0.55398566 -0.30393702]
[-3.9453447 -3.8318393 -3.709771 -3.5788126 -3.4386847 -3.2891636
-3.130095 -2.9614062 -2.783116 -2.5953472 -2.3983347 -2.1924343
-1.9781258 -1.756017 -1.5268404 -1.2914484 -1.0508031 -0.8059639
-0.55806917 -0.3083168 ]
[-3.9454095 -3.8320389 -3.7101152 -3.5793123 -3.4393506 -3.2900069
-3.131127 -2.9626384 -2.7845597 -2.5970137 -2.400235 -2.1945786
-1.9805245 -1.7586793 -1.5297745 -1.2946616 -1.054302 -0.80975324
-0.5621526 -0.31269658]]

z =
[[14.313813 14.315964 14.318469 14.321613 14.32581 14.33176
14.336363 14.340804 14.3467865 14.353908 14.362883 14.375611
14.396833 14.425026 14.465987 14.513266 14.562815 14.606856
14.643214 14.66736 ]
[15.887756 15.889947 15.892176 15.894657 15.897562 15.901045
15.903842 15.906494 15.9097185 15.91339 15.917785 15.923505
15.931823 15.942587 15.957335 15.975217 15.995712 16.016893
16.037842 16.055864 ]
[17.049894 17.050686 17.051254 17.051804 17.052402 17.053082
17.053614 17.054104 17.054684 17.055332 17.056093 17.057064
17.058443 17.06021 17.062592 17.065508 17.06892 17.072506
17.075472 17.073118 ]
[16.214447 16.216217 16.220085 16.225588 16.234282 16.247406
16.257439 16.271952 16.294804 16.321278 16.347477 16.389015
16.466505 16.561855 16.763414 17.039776 17.349918 17.527622
17.599398 17.604877 ]
[16.245964 16.247759 16.252758 16.262054 16.276989 16.29979
16.324738 16.356382 16.40259 16.464748 16.558044 16.786062
17.0495 17.200289 17.409216 17.999342 18.59744 18.943869
19.15316 19.170692 ]
[16.28217 16.284122 16.290758 16.303991 16.325975 16.360651
16.399502 16.44853 16.52168 16.627068 16.79588 17.173845
18.92067 19.113386 19.228382 19.299023 19.344383 19.369473
19.382442 19.383179 ]
[16.323608 16.32608 16.334759 16.352392 16.382248 16.430138
16.485277 16.565353 16.780577 17.677654 18.424421 18.532057
18.67504 19.089836 19.535816 19.812393 20.038866 20.185343
20.258522 20.274668 ]
[16.371004 16.373983 16.384985 16.407871 16.44792 16.516808
16.610392 16.779013 17.167183 17.883453 18.552233 19.228518
19.691988 19.881737 20.241898 20.834574 21.327736 21.648172
21.783743 21.800867 ]
[16.425554 16.429245 16.443497 16.474134 16.530468 16.6336
16.779413 17.02106 17.46875 18.117199 18.80158 19.484497
20.205254 21.034807 21.375565 22.387415 22.567026 22.65478
22.695255 22.702171 ]
[16.48819 16.493292 16.512716 16.554754 16.6334 16.777487
16.973152 17.264404 17.739105 18.376041 19.410532 22.322193
22.354116 22.378033 22.403164 22.425953 22.445843 22.461252
22.47197 22.473854 ]
[16.55854 16.56718 16.594595 16.652258 16.767515 17.132513
20.59621 21.945702 21.953814 21.957834 21.960566 21.963057
21.96607 21.969473 21.973572 21.978086 21.982708 21.98679
21.989103 21.983799 ]
[18.184958 21.26905 21.460497 21.465714 21.469286 21.472916
21.47512 21.476795 21.478771 21.48093 21.483362 21.486286
21.490614 21.495874 21.502464 21.50954 21.516348 21.521946
21.52526 21.520382 ]
[20.908823 20.90946 20.909956 20.910435 20.910942 20.911503
20.911966 20.912382 20.912865 20.913403 20.914026 20.914787
20.915852 20.917206 20.918976 20.921116 20.92352 20.925808
20.926884 20.921223 ]
[20.589975 20.591402 20.592667 20.594002 20.595535 20.597366
20.598888 20.600245 20.601871 20.603739 20.605932 20.60865
20.61267 20.61786 20.62473 20.632906 20.641865 20.65061
20.657906 20.659029 ]
[20.877579 20.878698 20.879612 20.880522 20.881517 20.882668
20.88362 20.884457 20.88545 20.886587 20.887917 20.889555
20.89199 20.895142 20.899307 20.904282 20.909763 20.915195
20.919708 20.919119 ]
[20.821203 20.82272 20.824125 20.825636 20.827387 20.829498
20.83127 20.832825 20.83469 20.836838 20.839352 20.842438
20.847073 20.85307 20.860958 20.870249 20.880203 20.889683
20.897478 20.899462 ]
[20.579361 20.587263 20.606749 20.645985 20.809416 20.972391
21.029253 21.057379 21.08351 21.105028 21.12341 21.140663
21.164244 21.188866 21.216295 21.24285 21.26572 21.282871
21.294615 21.298609 ]
[20.872255 20.8746 20.879995 20.891062 20.91357 20.964853
21.093004 21.401453 21.573086 21.650467 21.691422 21.718254
21.752502 21.782753 21.815449 21.845903 21.870775 21.887964
21.89876 21.900192 ]
[21.914911 21.915985 21.91685 21.917727 21.918709 21.91987
21.920858 21.921711 21.922726 21.9239 21.925274 21.926956
21.92948 21.932789 21.937172 21.942497 21.948465 21.95458
21.95997 21.9604 ]
[21.686197 21.686632 21.687008 21.687384 21.68778 21.688217
21.688595 21.688923 21.689297 21.689714 21.690193 21.690763
21.691551 21.692558 21.693865 21.695482 21.697365 21.699314
21.700686 21.698395 ]
[21.242893 21.243637 21.244297 21.244959 21.245663 21.24644
21.247116 21.247705 21.248377 21.249134 21.250002 21.251041
21.252481 21.254337 21.256767 21.259836 21.26354 21.267702
21.271664 21.272038 ]
[21.932615 21.93318 21.933693 21.934216 21.93478 21.935411
21.935955 21.936417 21.936949 21.93755 21.938238 21.939064
21.940254 21.941797 21.943804 21.946234 21.948948 21.951662
21.953585 21.951048 ]
[21.513063 21.514042 21.514896 21.515774 21.516747 21.517862
21.51885 21.5197 21.520687 21.521824 21.523136 21.524725
21.526989 21.529934 21.533794 21.538603 21.544203 21.550251
21.556028 21.558725 ]
[21.267338 21.268145 21.268858 21.269602 21.270437 21.27141
21.27227 21.272997 21.27384 21.274805 21.27591 21.277227
21.279089 21.281462 21.284462 21.28799 21.291725 21.295128
21.297138 21.293688 ]
[20.545183 20.545486 20.545723 20.545944 20.546175 20.546423
20.54664 20.546824 20.54703 20.54726 20.54752 20.547823
20.54823 20.548733 20.54935 20.550053 20.550735 20.55113
20.550392 20.544556 ]
[20.325447 20.32622 20.326859 20.32749 20.328161 20.328909
20.329573 20.330133 20.330772 20.331503 20.332335 20.333334
20.334726 20.336538 20.338902 20.341883 20.345427 20.349342
20.352962 20.352972 ]
[20.606873 20.60824 20.60949 20.610853 20.61246 20.61441
20.616177 20.617619 20.619314 20.621286 20.623545 20.62626
20.630175 20.635263 20.64176 20.649546 20.657953 20.66615
20.672838 20.67394 ]
[20.509209 20.510353 20.51137 20.512415 20.513567 20.514881
20.516077 20.517073 20.518219 20.519539 20.521046 20.522852
20.525372 20.528625 20.53277 20.537804 20.543379 20.548887
20.552881 20.549585 ]
[20.699625 20.700956 20.702156 20.70342 20.704845 20.7065
20.70803 20.709314 20.7108 20.712524 20.714504 20.716887
20.720217 20.72455 20.730122 20.737005 20.744852 20.753046
20.760065 20.760195 ]
[20.468256 20.469505 20.472555 20.478392 20.488081 20.502594
20.520546 20.537676 20.561481 20.592623 20.644712 20.710976
20.837364 21.067465 21.384876 21.706043 21.925213 22.046432
22.084719 22.084715 ]
[20.502464 20.50474 20.51082 20.521942 20.53975 20.566988
20.600801 20.63903 20.693974 20.773703 20.89891 21.164757
21.488718 21.645157 21.942432 22.566725 22.879276 23.226435
23.37105 23.36105 ]
[20.539028 20.541437 20.548954 20.563591 20.587805 20.625774
20.67341 20.727478 20.810947 20.993093 22.149906 22.266224
22.291168 22.307337 22.320976 22.333176 22.343012 22.35017
22.353893 22.349796 ]
[20.577251 20.582644 20.615046 21.010063 22.057549 22.06511
22.067507 22.068762 22.069984 22.071285 22.07269 22.074326
22.076607 22.079578 22.083368 22.088037 22.093332 22.098978
22.104258 22.10609 ]
[21.959843 21.960651 21.961306 21.961935 21.962595 21.963314
21.96398 21.964529 21.965145 21.965847 21.966635 21.967566
21.968807 21.970387 21.972368 21.974792 21.977526 21.980207
21.981503 21.975012 ]
[20.765831 20.767197 20.771086 20.776735 20.786068 20.801369
20.817577 20.829584 20.846834 20.879152 20.917301 20.971231
21.070385 21.257074 21.50744 21.682371 21.754982 21.780502
21.785727 21.779581 ]]

Does anybody have an idea on how to code the above?
thank you very much for any hint

@Jupiter

To run your code we need data uploaded somewhere, not pasted here with no comma, that should be inserted after each inner list.

Im sorry about that I just realized what you are pointing out.

Here is a link to the data:
data (json)

to parse data (once downloaded):

with open("datalink", 'r') as f:
        data_dict = json.load(f)

and then:

x = data_dict["x"]
y = data_dict["y"]
z = data_dict["z"]

Is that usable?
thanks

@Jupiter

If we define a go.Heatmap trace from your data, we get almost the same plot as with contourf , but the white space cannot be displayed because Plotly works only with uniform grids i.e.
with grids defined in the following way:

X = np.linspace(a, b, N)
Y = np.linspace(c, d, M)  # In the y direction your data are NOT uniform
X, Y = np.meshgrid(X, Y)
Z  of the shape as X and Y

y from the your json file gives the y-coordinates of a non-uniform grid (I analized both x and y).

import json
import numpy as np
import plotly.graph_objects as go

with open("data_for_contour.json", 'r') as f:
        data_dict = json.load(f)

x = data_dict["x"]
y = data_dict["y"]
z = data_dict["z"]
z = z=np.array(z).T
fig=go.Figure(go.Heatmap(x=np.array(x)[:, 0], y=np.array(y)[0], z=z, connectgaps=False,
                         zsmooth='best',
                         colorscale='Viridis', colorbar_thickness=25))
fig.update_layout(width=500, height=500)

Unfortunately the conturf cannot be reproduced, because Plotly cannot generate a Heatmap or a Contour trace from irregularly spaced data.

Thank you very much for your input, and for clearing up that Plotly does not support the irregular data on the y-axis. Hence the problem of replicating contourf

I was playing around with coloring the scatter type of Plotly to achieve what I’m looking for:

import plotly.graph_objs as go
import plotly.offline as py_off

data = []
data.append(go.Scatter(
            x = x.flatten(),
            y = y.flatten(),
            mode='markers',
            connectgaps = True,
            marker=dict(color= z.flatten(), colorscale='Viridis', size=14, 
                        colorbar=dict(title= "unit",
                                      thickness=20,
                                      titleside ='top',
                        ),
                        )
                        )
            )
            
fig = go.Figure(data=data)
py_off.plot(fig, filename = "test.html")

The result yields the support of the irregular data, however that approach is then missing the fill or smooth between dots vertically. Is that somehow possible?

thanks again