5
$\begingroup$

from a simulation i have a 3 dimensional dataset in the form {{x1,y1,z1},{x2,y2,z2},...}. Now i want to plot these datapoints using ListPlot3d for example. I do not want to interpolate between the datapoints! The Problem is that areas with no dataspoints are plottet anyway.

data={{0.005,2.5,2.17859},{0.005,2.7,3.29422},{0.005,2.9,4.18894},{0.005,3.1,4.94474},{0.005,3.3,5.58497},{0.005,3.5,6.12328},{0.0052,2.5,2.82223},{0.0052,2.7,3.86527},{0.0052,2.9,4.72697},{0.0052,3.1,5.44918},{0.0052,3.3,6.04614},{0.0052,3.5,6.55115},{0.0054,2.5,3.44993},{0.0054,2.7,4.44714},{0.0054,2.9,5.26443},{0.0054,3.1,5.93569},{0.0054,3.3,6.4982},{0.0054,3.5,6.96563},{0.0056,2.7,5.01079},{0.0056,2.9,5.77741},{0.0056,3.1,6.39913},{0.0056,3.3,6.9346},{0.0056,3.5,7.37356},{0.0058,2.5,4.67146},{0.0058,2.7,5.56134},{0.0058,2.9,6.28327},{0.0058,3.1,6.85945},{0.0058,3.3,7.35591},{0.0058,3.5,7.76783},{0.006,2.5,5.26045},{0.006,2.7,6.09937},{0.006,2.9,6.76066},{0.006,3.1,7.30496},{0.006,3.3,7.76015},{0.006,3.5,8.15299},{0.0062,2.5,5.83747},{0.0062,2.7,6.60495},{0.0062,2.9,7.22496},{0.0062,3.1,7.7294},{0.0062,3.3,8.15356},{0.0062,3.5,8.52506},{0.0064,2.5,6.39799},{0.0064,2.7,7.11053},{0.0064,2.9,7.69154},{0.0064,3.1,8.15527},{0.0064,3.3,8.541},{0.0064,3.5,8.88887},{0.0066,2.5,6.94001},{0.0066,2.7,7.60756},{0.0066,2.9,8.13278},{0.0066,3.1,8.55552},{0.0066,3.3,8.92445},{0.0066,3.5,9.23019},{0.0068,2.5,7.47377},{0.0068,2.7,8.06987},{0.0068,3.1,8.96118},{0.0068,3.3,9.28883},{0.0068,3.5,9.57607},{0.007,2.5,7.98162},{0.007,2.7,8.53929},{0.007,2.9,8.96601},{0.007,3.1,9.34178},{0.007,3.3,9.64951},{0.007,3.5,9.89291},{0.004,3,1.84467},{0.0042,2.6,0.360109},{0.0042,2.8,1.41482},{0.0042,3,2.41145},{0.0044,2.4,0.998343},{0.0044,2.6,0.87138},{0.0044,2.8,2.01633},{0.0044,3,2.97738},{0.0046,2.2,2.13105},{0.0046,2.4,0.378328},{0.0046,2.6,1.50364},{0.0046,2.8,2.61101},{0.0046,3,3.51484},{0.0048,2,3.7272},{0.0048,2.2,1.3613},{0.0048,2.4,0.878496},{0.0048,2.6,2.13361},{0.0048,2.8,3.19259},{0.0048,3,4.06767},{0.005,2,2.83163},{0.005,2.2,0.694599},{0.005,2.4,1.55004},{0.005,2.6,2.76217},{0.005,2.8,3.75311},{0.005,3,4.60029},{0.0052,2,2.02031},{0.0052,2.2,0.853445},{0.0052,2.4,2.21617},{0.0052,2.6,3.3688},{0.0052,2.8,4.32188},{0.0052,3,5.10558},{0.0054,2,1.29896},{0.0054,2.2,1.49253},{0.0054,2.4,2.86949},{0.0054,2.6,3.97373},{0.0054,2.8,4.86902},{0.0054,3,5.60718},{0.0056,2,0.91892},{0.0056,2.2,2.22357},{0.0056,2.4,3.51484},{0.0056,2.6,4.5704},{0.0056,2.8,5.42015},{0.0056,3,6.10564},{0.0058,2,1.44044},{0.0058,2.2,2.91988},{0.0058,2.4,4.14681},{0.0058,2.6,5.14629},{0.0058,2.8,5.92999},{0.0058,3,6.57278},{0.006,2,2.11568},{0.006,2.2,3.60964},{0.006,2.4,4.77195},{0.006,2.6,5.69827},{0.006,2.8,6.44696},{0.006,3,7.04164},{0.0048,2,3.7272},{0.005,1.9,4.29313},{0.005,2,2.83163},{0.0052,1.8,5.01847},{0.0052,1.9,3.35941},{0.0052,2,2.02031},{0.0054,1.7,5.97469},{0.0054,1.8,4.03038},{0.0054,1.9,2.49515},{0.0054,2,1.29896},{0.0056,1.6,7.23521},{0.0056,1.7,4.88952},{0.0056,1.8,3.11004},{0.0056,1.9,1.72853},{0.0056,2,0.91892},{0.0058,1.6,6.05923},{0.0058,1.7,3.90655},{0.0058,1.8,2.28477},{0.0058,1.9,1.09399},{0.0058,2,1.44044},{0.006,1.5,7.63176},{0.006,1.6,4.95186},{0.006,1.7,2.98507},{0.006,1.8,1.57253},{0.006,1.9,1.42393},{0.006,2,2.11568},{0.0062,1.5,6.37579},{0.0062,1.6,3.93074},{0.0062,1.7,2.18144},{0.0062,1.8,1.44613},{0.0062,1.9,2.09063},{0.0062,2,2.87604},{0.0064,1.5,5.21774},{0.0064,1.6,3.00755},{0.0064,1.7,1.55374},{0.0064,1.8,2.07269},{0.0064,1.9,2.80117},{0.0064,2,3.64237},{0.0066,1.5,4.14823},{0.0066,1.6,2.22556},{0.0066,1.7,2.04764},{0.0066,1.8,2.76672},{0.0066,1.9,3.60593},{0.0066,2,4.37796},{0.0068,1.5,3.21053},{0.0068,1.6,2.05988},{0.0068,1.7,2.78893},{0.0068,1.8,3.52765},{0.0068,1.9,4.39647},{0.0068,2,5.10558},{0.007,1.5,2.38498},{0.007,1.6,2.77754},{0.007,1.7,3.49662},{0.007,1.8,4.36857},{0.007,1.9,5.15512},{0.007,2,5.80502}};

 ListPlot3D[data, Mesh -> None, InterpolationOrder -> 0, ColorFunction->"Rainbow", Filling -> Bottom,FillingStyle -> {Opacity[0.9]},PlotRange -> {Automatic, Automatic, {-1, 20}}]

listplot3d of data

As you see there are long,straight bars to the side of the plot. In these areas there are no data points. Is there a possiblity to remove those bars? One possibility would be to add some zero values at the points without data... (ListDensityPlot has the same problem). Has someone an idea to solve this problem?

$\endgroup$
5
  • $\begingroup$ Are you perhaps looking for Histogram3D? $\endgroup$
    – user21
    Dec 12, 2016 at 11:44
  • $\begingroup$ I tried this. My data has the form {x,y,z}. To use Histogramm3d I have to convert the data into multiple {x,y}.. $\endgroup$ Dec 12, 2016 at 12:07
  • 1
    $\begingroup$ And you don't want ListPointPlot3D I assume? $\endgroup$
    – user484
    Dec 12, 2016 at 12:12
  • $\begingroup$ ListPointPlot3d with bars so to say $\endgroup$ Dec 12, 2016 at 12:39
  • $\begingroup$ Use Filling -> Bottom in ListPointPlot3D. I don't know any function which does what you want automatically. You'll have to work for it. $\endgroup$
    – Szabolcs
    Dec 12, 2016 at 12:45

2 Answers 2

6
$\begingroup$

I would build the graphics out of Cuboid objects manually.

It is also possible to abuse Histogram3D to handle already binned data by constructing a WeightedData object and setting the bin sizes manually.

Histogram3D[
 WeightedData[
  data[[All, {1, 2}]],
  data[[All, 3]]
  ],
 {{0.0002}, {0.1}},
 ColorFunction -> "Rainbow"
 ]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks a lot i will try to do it this way. (There are some multiples datapoints in data) $\endgroup$ Dec 12, 2016 at 12:56
  • $\begingroup$ @PhilippHeil What do you want to show when there are multiple points? Bars would overlap. Use GroupBy to combine the duplicate points in a way appropriate for your use case. $\endgroup$
    – Szabolcs
    Dec 12, 2016 at 13:09
  • $\begingroup$ Just data2=DeleteDuplicates[data] so that there are no more duplicates $\endgroup$ Dec 12, 2016 at 13:23
1
$\begingroup$

Here is my workarround: I made an array out of the data and added None where there is no data.

ybins = Sort[DeleteDuplicates[data[[All, 1]]]];
xbins = Sort[DeleteDuplicates[data[[All, 2]]]];
ny = Length[ybins];
nx = Length[xbins];
nyi = Table[Count[data[[All, 1]], ybins[[i]]], {i, 1, Length[ybins]}];
nxi = Table[Count[data[[All, 2]], xbins[[i]]], {i, 1, Length[xbins]}];
posx[i_] := Position[xbins, data[[i, 2]]][[1, 1]]
posy[i_] := Position[ybins, data[[i, 1]]][[1, 1]]
novalues = Table[None, {x, 1, nx}, {y, 1, ny}];
Export["novalues.txt", novalues, "Table"];

Do[novalues = Import["novalues.txt", "Table"];
novalues2 = ReplacePart[novalues, {posx[i], posy[i]} -> data[[i, 3]]];
Export["novalues.txt", novalues2, "Table"], {i, 1, Length[data], 1}];
arraytab = Import["novalues.txt", "Table"];
ListPlot3D[arraytab, InterpolationOrder -> 0, 
ColorFunction -> "Rainbow", Filling -> Bottom, 
FillingStyle -> {Opacity[0.9]}, PlotRange -> {0.1, 10}, Mesh -> None]

enter image description here

$\endgroup$
1
  • $\begingroup$ Missing[] is the more conventional symbol used for the absence of data. $\endgroup$ Dec 12, 2016 at 14:47

Your Answer

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

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