3
$\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
$\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

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

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.