4
$\begingroup$

How can I add a color bar to my graph?

xyz = Flatten[Table[{i, j, k}, {i, 1, 10, .35}, {j, 1, 10, .35}, {k, 1, 10, .35}], 2];

f[x_, y_, z_] :=  (1 + z) + Im[Sqrt[-( (z))^2 - x z]]

Graphics3D[Point[xyz, VertexColors -> (Hue /@ Rescale[f[##] & @@@ xyz])], Axes -> True, AxesLabel -> {x, y, z}]
$\endgroup$

1 Answer 1

2
$\begingroup$

first define another colorfunction

cf := If[# > 0, Hue[#/200], Black] &

then I would use ListPointPlot3D

 ListPointPlot3D[xyz, 
 ColorFunction -> Function[{x, y, z}, cf@f[x, y, z]], 
 ColorFunctionScaling -> False, 
 PlotLegends -> BarLegend[{cf, {-100, 200}}], BoxRatios -> {1, 1, 1}]

enter image description here

$\endgroup$
9
  • $\begingroup$ your colorbar doesn't show values of the function correctly $\endgroup$ Commented Aug 3, 2017 at 10:54
  • $\begingroup$ Ok, but I can not choose your answer because it is not complete $\endgroup$ Commented Aug 3, 2017 at 10:58
  • $\begingroup$ I didnt find it $\endgroup$ Commented Aug 3, 2017 at 11:20
  • $\begingroup$ BarLegend doesnt have such a option $\endgroup$ Commented Aug 3, 2017 at 11:48
  • $\begingroup$ Is there any option which can show negative parts of the graph in forexample black? $\endgroup$ Commented Aug 3, 2017 at 11:53

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.