1
$\begingroup$

enter image description hereI am very new in Mathematica and I want to draw a temperature map. I have data which gives me the value of temperature in each spherical shell (the radius of the sphere is divided into number of concentric shells) and I need to color each spherical shell according to the value of temperature. I have tried the following. But I am not getting the radial color according to the "val" and also the color bar. Please help. Thanks a lot.

    val = ListInterpolation[{8, 8, 8, 4, 4, 4, 0, 0, 0}, {{0, 1.1}}]

Export["~/Desktop/earth-like.jpg", 
 RegionPlot3D[(x^2 + y^2 + z^2 <= 1) && (x < 0 || y > 0 || 
     z < 0), {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
  ColorFunction -> 
   Function[{x, y, z}, 
    ColorData["TemperatureMap"][val[Sqrt[(x^2 + y^2 + z^2)]]]], 
  PlotPoints -> 100, Mesh -> False, Boxed -> False, Axes -> False, 
  ColorFunctionScaling -> False, Lighting -> "Neutral", 
  AxesLabel -> {X, Y, Z}, {ViewPoint -> {2, -0.5, 0.5}}]]
$\endgroup$
  • $\begingroup$ Your code is not valid, working Mathematica code and it is essentially unreadable as well. Please edit the code in something that can be evaluated. $\endgroup$ – m_goldberg Oct 11 '17 at 15:25
  • $\begingroup$ Sorry. Thanks for your comment. I have corrected it. Please check again and try to help me. Thanks again. $\endgroup$ – Nirmalendu Oct 13 '17 at 7:52
3
$\begingroup$

Here's one possibility:

fun = ListInterpolation[{8, 8, 8, 4, 4, 4, 0, 0, 0}, {{0, 1.1}}];

reg = BoundaryDiscretizeRegion[RegionDifference[Ball[{0, 0, 0}, 11/10], 
                               ConicHullRegion[{{0, 0, 0}},
                                               {{1, 0, 0}, {0, -1, 0}, {0, 0, 1}} 11/10]],
                               MaxCellMeasure -> {"Length" -> 0.02},
                               Method -> "RegionPlot3D"];

SliceDensityPlot3D[fun[Sqrt[x^2 + y^2 + z^2]], reg,
                   {x, -1.1, 1.1}, {y, -1.1, 1.1}, {z, -1.1, 1.1}, 
                   ColorFunction -> "TemperatureMap", PlotPoints -> 545]

plot

$\endgroup$
  • $\begingroup$ Thanks. What is about the colorbar with values? $\endgroup$ – Nirmalendu Oct 14 '17 at 11:25
  • $\begingroup$ Look up PlotLegend. $\endgroup$ – J. M.'s discontentment Oct 14 '17 at 11:34
  • $\begingroup$ Thanks for your help. $\endgroup$ – Nirmalendu Oct 19 '17 at 14:23

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.