7
$\begingroup$

Bug introduced in 12.0 or earlier and persisting through 12.0.


I was trying to plot a simple $n\times3$-sized $(x_i,y_i,z_i)$ matrix data with ListPlot3D, which is basically three lines along $y$-direction. However, the middle part is completely lost and there seems other distortion as well. It doesn't occur when I check with ListPlot for each of the three lines.enter image description here

ListPlot3D[ha, PlotRange -> All, Mesh -> All, 
 AxesLabel -> {"x", "y", "z"}, ImageSize -> Large]

And the data

ha = {{0.`, 0.`, 1.000000000000001`}, {0.`, 0.04220866428763286`, 
    1.000000000000001`}, {0.`, 0.16116035455278002`, 
    1.0000000000000013`}, {0.`, 0.3568550707954415`, 
    1.000000000000001`}, {0.`, 0.6292928130156172`, 
    1.000000000000001`}, {0.`, 0.9784735812133072`, 
    1.0000000000000009`}, {0.`, 1.4043973753885115`, 
    1.000000000000001`}, {0.`, 1.9070641955412304`, 
    1.000000000000001`}, {0.`, 2.486474041671463`, 
    1.000000000000001`}, {0.`, 3.1426269137792096`, 
    1.0000000000000009`}, {0.`, 3.8755228118644713`, 
    1.0000000000000007`}, {0.`, 4.685161735927248`, 
    1.0000000000000002`}, {0.`, 5.571543685967537`, 
    0.9999999999999999`}, {0.`, 6.534668661985342`, 
    0.9999999999999993`}, {0.`, 7.574536663980662`, 
    0.9999999999999986`}, {0.`, 8.691147691953493`, 
    0.9999999999999974`}, {0.`, 9.884501745903842`, 
    0.9999999999999963`}, {0.`, 11.154598825831703`, 
    0.9999999999999954`}, {0.`, 12.501438931737077`, 
    0.9999999999999949`}, {0.`, 13.925022063619968`, 
    0.9999999999999942`}, {0.`, 15.425348221480373`, 
    0.9999999999999936`}, {0.`, 17.002417405318294`, 
    0.9999999999999928`}, {0.`, 18.656229615133725`, 
    0.9999999999999922`}, {0.`, 20.386784850926674`, 
    0.9999999999999916`}, {0.`, 22.194083112697136`, 
    0.999999999999991`}, {0.`, 24.07812440044511`, 
    0.9999999999999905`}, {0.`, 26.038908714170606`, 
    0.99999999999999`}, {0.`, 28.076436053873604`, 
    0.9999999999999896`}, {0.`, 30.190706419554125`, 
    0.9999999999999892`}, {0.`, 32.381719811212164`, 
    0.999999999999989`}, {0.`, 34.6494762288477`, 
    0.9999999999999887`}, {0.`, 36.99397567246076`, 
    0.9999999999999886`}, {0.`, 39.41521814205134`, 
    0.9999999999999883`}, {0.`, 41.91320363761943`, 
    0.9999999999999883`}, {0.`, 44.48793215916504`, 
    0.9999999999999883`}, {0.`, 47.13940370668815`, 
    0.9999999999999883`}, {0.`, 49.86761828018879`, 
    0.9999999999999885`}, {0.`, 52.67257587966694`, 
    0.9999999999999885`}, {0.`, 55.55427650512259`, 
    0.9999999999999887`}, {0.`, 58.512720156555766`, 
    0.999999999999989`}, {0.`, 61.54790683396646`, 
    0.9999999999999892`}, {0.`, 64.65983653735468`, 
    0.9999999999999895`}, {0.`, 67.84850926672038`, 
    0.9999999999999897`}, {0.`, 71.11392502206361`, 
    0.9999999999999901`}, {0.`, 74.45608380338437`, 
    0.9999999999999905`}, {0.`, 77.87498561068263`, 
    0.9999999999999907`}, {0.`, 81.37063044395842`, 
    0.9999999999999932`}, {0.`, 84.94301830321169`, 
    0.9999999999999886`}, {0.`, 88.59214918844249`, 
    0.9999999999999765`}, {0.`, 92.31802309965083`, 
    1.0000000000004379`}, {0.`, 96.12064003683665`, 
    1.0000000000025797`}, {0.`, 100.`, 1.0000000000017453`}, {0.001`, 
    0.`, 0.9851456965785419`}, {0.001`, 0.04220866428763286`, 
    0.9807978862177816`}, {0.001`, 0.16116035455278002`, 
    0.9701113707294763`}, {0.001`, 0.3568550707954415`, 
    0.9551775783456566`}, {0.001`, 0.6292928130156172`, 
    0.938966241440333`}, {0.001`, 0.9784735812133072`, 
    0.9251572107453561`}, {0.001`, 1.4043973753885115`, 
    0.9164358919538024`}, {0.001`, 1.9070641955412304`, 
    0.9134215526191046`}, {0.001`, 2.486474041671463`, 
    0.9150120137733051`}, {0.001`, 3.1426269137792096`, 
    0.9194496552196791`}, {0.001`, 3.8755228118644713`, 
    0.9251679949629803`}, {0.001`, 4.685161735927248`, 
    0.9311110359028776`}, {0.001`, 5.571543685967537`, 
    0.9366974449748587`}, {0.001`, 6.534668661985342`, 
    0.9416642637206076`}, {0.001`, 7.574536663980662`, 
    0.9459077703484071`}, {0.001`, 8.691147691953493`, 
    0.9492727960322465`}, {0.001`, 9.884501745903842`, 
    0.9496894601285651`}, {0.001`, 11.154598825831703`, 
    0.9444346395454216`}, {0.001`, 12.501438931737077`, 
    0.9380124889601578`}, {0.001`, 13.925022063619968`, 
    0.930814905086062`}, {0.001`, 15.425348221480373`, 
    0.9227876161420403`}, {0.001`, 17.002417405318294`, 
    0.9138395812502855`}, {0.001`, 18.656229615133725`, 
    0.9038615966962887`}, {0.001`, 20.386784850926674`, 
    0.8927270336346949`}, {0.001`, 22.194083112697136`, 
    0.8802896371980299`}, {0.001`, 24.07812440044511`, 
    0.8663800048610383`}, {0.001`, 26.038908714170606`, 
    0.8508008043504566`}, {0.001`, 28.076436053873604`, 
    0.8333203705082056`}, {0.001`, 30.190706419554125`, 
    0.8136640055561997`}, {0.001`, 32.381719811212164`, 
    0.7915018693467315`}, {0.001`, 34.6494762288477`, 
    0.766431608818418`}, {0.001`, 36.99397567246076`, 
    0.7379525357279786`}, {0.001`, 39.41521814205134`, 
    0.7054255687489583`}, {0.001`, 41.91320363761943`, 
    0.668007778358783`}, {0.001`, 44.48793215916504`, 
    0.624538218099993`}, {0.001`, 47.13940370668815`, 
    0.5733210576487527`}, {0.001`, 49.86761828018879`, 
    0.5116622654510867`}, {0.001`, 52.67257587966694`, 
    0.4346902749397748`}, {0.001`, 55.55427650512259`, 
    0.33130339884032495`}, {0.001`, 58.512720156555766`, 
    0.15427506080560502`}, {0.001`, 61.54790683396646`, 
    2.5075562949280167`*^-11}, {0.001`, 64.65983653735468`, 
    2.5923992398533742`*^-20}, {0.001`, 67.84850926672038`, 
    3.0004356639293435`*^-13}, {0.001`, 71.11392502206361`, 
    4.399460615423633`*^-40}, {0.001`, 74.45608380338437`, 
    1.3035336686132412`*^-50}, {0.001`, 77.87498561068263`, 
    1.7915749403987287`*^-61}, {0.001`, 81.37063044395842`, 
    1.2546835829365311`*^-72}, {0.001`, 84.94301830321169`, 
    4.257926544060667`*^-15}, {0.001`, 88.59214918844249`, 
    1.0989735816206881`*^-95}, {0.001`, 92.31802309965083`, 
    5.372616958607281`*^-16}, {0.001`, 96.12064003683665`, 
    1.3462554804969502`*^-119}, {0.001`, 100.`, 
    9.396462133027396`*^-17}, {0.002`, 0.`, 
    0.9702854194086491`}, {0.002`, 0.04220866428763286`, 
    0.9615799650874828`}, {0.002`, 0.16116035455278002`, 
    0.9401603623570034`}, {0.002`, 0.3568550707954415`, 
    0.910139922530339`}, {0.002`, 0.6292928130156172`, 
    0.8773792041918361`}, {0.002`, 0.9784735812133072`, 
    0.8492795318523028`}, {0.002`, 1.4043973753885115`, 
    0.8314175647052442`}, {0.002`, 1.9070641955412304`, 
    0.8252191223825608`}, {0.002`, 2.486474041671463`, 
    0.8284882720732185`}, {0.002`, 3.1426269137792096`, 
    0.8375951953414753`}, {0.002`, 3.8755228118644713`, 
    0.8492937637750858`}, {0.002`, 4.685161735927248`, 
    0.8614112641110805`}, {0.002`, 5.571543685967537`, 
    0.8727670039728884`}, {0.002`, 6.534668661985342`, 
    0.8828376709411946`}, {0.002`, 7.574536663980662`, 
    0.8914244712269536`}, {0.002`, 8.691147691953493`, 
    0.8982243070632591`}, {0.002`, 9.884501745903842`, 
    0.8990833912251011`}, {0.002`, 11.154598825831703`, 
    0.8884740950975214`}, {0.002`, 12.501438931737077`, 
    0.8754686706446855`}, {0.002`, 13.925022063619968`, 
    0.8608453837805503`}, {0.002`, 15.425348221480373`, 
    0.8444696050275246`}, {0.002`, 17.002417405318294`, 
    0.8261211194573721`}, {0.002`, 18.656229615133725`, 
    0.8055266044958076`}, {0.002`, 20.386784850926674`, 
    0.7823531323815934`}, {0.002`, 22.194083112697136`, 
    0.7561911959487542`}, {0.002`, 24.07812440044511`, 
    0.7265273871355553`}, {0.002`, 26.038908714170606`, 
    0.6927009191720127`}, {0.002`, 28.076436053873604`, 
    0.6538313467191086`}, {0.002`, 30.190706419554125`, 
    0.6086901588358097`}, {0.002`, 32.381719811212164`, 
    0.5554510907737478`}, {0.002`, 34.6494762288477`, 
    0.49113879517423953`}, {0.002`, 36.99397567246076`, 
    0.41015049580923046`}, {0.002`, 39.41521814205134`, 
    0.29863294585807315`}, {0.002`, 41.91320363761943`, 
    0.061015753817889956`}, {0.002`, 44.48793215916504`, 
    6.734785731890138`*^-20}, {0.002`, 47.13940370668815`, 
    1.19665072428201`*^-12}, {0.002`, 49.86761828018879`, 
    6.834579450050555`*^-11}, {0.002`, 52.67257587966694`, 
    1.2923868774029326`*^-49}, {0.002`, 55.55427650512259`, 
    1.5623363881240579`*^-13}, {0.002`, 58.512720156555766`, 
    8.20616019091291`*^-72}, {0.002`, 61.54790683396646`, 
    1.9387838158153854`*^-83}, {0.002`, 64.65983653735468`, 
    1.776546358835029`*^-23}, {0.002`, 67.84850926672038`, 
    1.4018676559249928`*^-107}, {0.002`, 71.11392502206361`, 
    1.8702205077648395`*^-27}, {0.002`, 74.45608380338437`, 
    1.8814412334525443`*^-33}, {0.002`, 77.87498561068263`, 
    2.4699959562643973`*^-36}, {0.002`, 81.37063044395842`, 
    8.528212719579378`*^-159}, {0.002`, 84.94301830321169`, 
    4.0595031104357706`*^-172}, {0.002`, 88.59214918844249`, 
    1.2652311634065102`*^-185}, {0.002`, 92.31802309965083`, 
    2.63650817206882`*^-199}, {0.002`, 96.12064003683665`, 
    1.3352789152157276`*^-27}, {0.002`, 100.`, 
    2.0318155449586684`*^-29}};
$\endgroup$
5
  • $\begingroup$ Trying to rotate the figure causes my FrontEnd to hang... $\endgroup$ Feb 9, 2020 at 21:22
  • $\begingroup$ it has to do to how some of your data are aligned I think. Try adding this option and see if it helps MaxPlotPoints -> Length[ha] $\endgroup$
    – Nasser
    Feb 9, 2020 at 21:43
  • $\begingroup$ @Nasser With that option, It's still wrong and incomplete in a different way, as one can see from plotting each lines. $\endgroup$
    – xiaohuamao
    Feb 9, 2020 at 22:31
  • $\begingroup$ @SjoerdC.deVries Weird... Not a large data set at all. $\endgroup$
    – xiaohuamao
    Feb 9, 2020 at 22:32
  • $\begingroup$ @xiaohuanmao, can you explain where these numbers are from? $\endgroup$
    – boobami
    Feb 10, 2020 at 19:09

2 Answers 2

6
$\begingroup$

The issue seems to be caused by vastly different scales in x and y coordinates. We can replicate the issue by re-scaling one of the first two columns:

SeedRandom[1]
dt1 = Join @@ MapIndexed[Append[#2, #] &, RandomReal[1, {5, 10}], {2}];

dt2 = MapAt[10^-4 # &, dt1, {All, 1}]; 

Row[ListPlot3D[#, ImageSize -> 400] & /@ {dt1, dt2}]

enter image description here

An easy fix is to (1) re-scale each column to the unit interval, (2) ListPlot3D the re-scaled data, and (3) post-process to undo the scaling:

ClearAll[reScale, scaleBack, undoScaling]

reScale = Transpose @* Map[Rescale] @* Transpose;

scaleBack = Transpose[MapThread[Rescale, 
   {Transpose[#], MinMax /@ Transpose[#], MinMax /@ Transpose[#2]}]] &;

undoScaling[x_] := # /. GraphicsComplex[a_, b__] :> GraphicsComplex[scaleBack[a, x], b]&

lp3D = undoScaling[ha] @ ListPlot3D[reScale @ ha, Mesh -> All];

Show[ListPointPlot3D[ha], lp3D, ImageSize -> Large, AxesLabel -> {"x", "y", "z"}]

enter image description here

$\endgroup$
6
$\begingroup$

Not certain what is going on but you can work around with Interpolation.

ifoo = Interpolation[ha, InterpolationOrder -> 1];

Show[
 ListPointPlot3D[ha, 
  PlotRange -> All, 
  AxesLabel -> {"x", "y", "z"}, 
  ImageSize -> Large],
 Plot3D[ifoo[x, y], 
  Evaluate[Sequence @@ MapThread[Prepend, {ifoo["Domain"], {x, y}}]], 
  PlotStyle -> Opacity[.5], 
  MeshFunctions -> {#3 &}]
 ]

Mathematica graphics

You should send your example to Wolfram Support as I think it should work with the InterpolationOrder option of ListPlot3D but that does not appear to change the plot. Would like to know what they come up with.

Hope this helps.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.