3
$\begingroup$

I would like to know whether I can use Histogram3D to plot a set of points with three given values. I want to plot the values {0, 0, 0.01}, {0, 1, 0.1}, {1, 0, 0.02}, {1, 1, 0.1} using Histogram3D. I tried the following command Histogram3D[{{0, 0, 0.01}, {0, 1, 0.1}, {1, 0, 0.02}, {1, 1, 0.1}}] but I wasn't successful! I also tried importing these values from an CSV file but also didn't work. Is there a way I can simply plot three values?

$\endgroup$
  • 3
    $\begingroup$ Does this answer your question? How can I imitate the style of a certain 3D bar chart? $\endgroup$ – yarchik Jul 5 '20 at 11:34
  • $\begingroup$ Try Histogram3D[RandomChoice[{0.01, 0.02, 0.1, 0.1} -> {{0,0}, {1,0}, {0,1},{1,1}}, 1000]] $\endgroup$ – yarchik Jul 5 '20 at 11:57
  • $\begingroup$ Actually, I don’t want to create random numbers. I have the x,y,z values. We have 100 elements. The x and y are integers that have the following values 0,1,2,3,4,5,6,7,8,9. The z values are real numbers that range between 0.0 and 1.0. We can think of it as a matrix for each xy element we have a z value. But I want to plot them using Histogram3D. $\endgroup$ – Naps Jul 5 '20 at 14:24
5
$\begingroup$

A data set of 100 triples:

xy = Tuples[Range[0, 9], 2];
SeedRandom[1]
z = RandomReal[1, 100];
xyz = Join[xy, List /@ z, 2]; 

Construct a WeightedData object from the list xyz using the first two columns as values and the last column as weights:

wd = WeightedData[xyz[[All, ;; 2]], xyz[[All, -1]]];

Use wd with Histogram3D:

Histogram3D[wd, ColorFunction -> "Rainbow"]

enter image description here

Add the option ChartElementFunction -> "Cylinder" to get

enter image description here

$\endgroup$
3
$\begingroup$

I'm guessing you are looking for something like this:

data = {{0, 0, 0.01}, {0, 1, 0.1}, {1, 0, 0.02}, {1, 1, 0.1}};
bars =
  With[{r = .25},
   Tooltip[Cylinder[{{#1, #2, 0}, {#1, #2, #3}}, r], {#1, #2, #3}] & @@@ data];
Graphics3D[bars, Axes -> True, BoxRatios -> {1, 1, 1}]

chart

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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