0
$\begingroup$

I have a data set in form of {x,y} (I add part of my data set), and I need to calculate the 3D histogram for it, also I need to get -LOG from probability (Z axes). I wrote this code for it.

Energy2 =
SmoothHistogram3D[togather,
ScalingFunctions -> {"None", "None", -Log[#] &}, ImageSize -> Full,
ColorFunction -> "TemperatureMap",
AxesLabel -> {"Radius Of Gyration(\[Angstrom])",
"Number of Native Contacts", "Energy"}, PlotRange -> All]

and I will get this error message, "Message text not found -- ({None,None,-Log[#1]&})", what is wrong with my code?

{{16.3009, 9345}, {16.2118, 9470}, {15.8156, 9439}, {15.9585, 9542},
{15.6112, 9414}, {15.7221, 9370}, {15.509, 9450}, {15.6993, 9398},
{16.4999, 9487}, {16.3784, 9453}, {16.9554, 9684}, {16.9463, 9506},
{16.9786, 9549}, {17.2081, 9461}, {17.4898, 9398}, {17.1521, 9674},
{17.92, 8789}, {18.0992, 8740}, {18.1392, 8549}, {18.5486, 8501},
{18.9874, 8727}, {18.9643, 8710}, {18.5903, 8681}, {18.6687, 8687},
{17.8913, 8784}, {18.1319, 8517}, {18.6675, 8632}, {18.9163, 8868},
{18.2755, 8446}, {18.2921, 8541}, {18.629, 8426}, {18.876, 8359}}
$\endgroup$
8
  • 4
    $\begingroup$ You should share a minimal example of your code that shows the problem in order for people to be able to help you. $\endgroup$ – Thies Heidecke Nov 9 '16 at 15:58
  • $\begingroup$ I tried to add my code by I got error message!!! $\endgroup$ – Parviz Nov 9 '16 at 16:39
  • $\begingroup$ ROGF = Import["RoGf-B4MS.dat", "Table"]; NCF = Import["nativenumcontacts-folded.dat", "Table"]; ROGF = Map[#[[2]] &, ROGF]; NCF = Map[#[[2]] + #[[3]] &, NCF]; togather = Table[{ROGF[[i]], NCF[[i]]}, {i, 1, Length[ROGF]}]; Energy2 = SmoothHistogram3D[togather, ScalingFunctions -> {None, None, -Log[#] &}, ImageSize -> Full, ColorFunction -> "TemperatureMap", AxesLabel -> {"Radius Of Gyration([Angstrom])", "Number of Native Contacts", "Energy"}, PlotRange -> All] "code with smoothHistogram3D" $\endgroup$ – Parviz Nov 9 '16 at 16:39
  • $\begingroup$ part of data set in format {x(dat1),y(dat2)}:{{16.3009, 9345}, {16.2118, 9470}, {15.8156, 9439}, {15.9585, 9542}, {16.2253, 9563}, {16.284, 9411}, {15.6112, 9414}, {15.7221, 9370}, {15.509, 9450}, {15.6993, 9398}, {15.961, 9431}, {16.6001, 9464}, {16.3766, 9372}, {16.4999, 9487}, {16.3784, 9453}, {16.9554, 9684}, {16.9463, 9506}, {17.2453, 9355}, {17.0854, 9710}, {16.9786, 9549}, {17.2081, 9461}, {17.4898, 9398}, {17.1521, 9674}, {17.8233, 9266}, {17.726, 9389}, {17.7837, 9575}, {17.5088, 9566}, {17.8232, 9569}, {18.4418, 9443}, {17.8446, 9602}} $\endgroup$ – Parviz Nov 9 '16 at 16:50
  • $\begingroup$ What is togather? The data provided below? $\endgroup$ – anderstood Nov 10 '16 at 15:23
3
$\begingroup$

Maybe it's your version of Mathematica. Using 10.4.1 (Windows 7) the following works:

togather = {{16.3009, 9345}, {16.2118, 9470}, {15.8156, 
    9439}, {15.9585, 9542}, {15.6112, 9414}, {15.7221, 9370}, {15.509,
     9450}, {15.6993, 9398}, {16.4999, 9487}, {16.3784, 
    9453}, {16.9554, 9684}, {16.9463, 9506}, {16.9786, 
    9549}, {17.2081, 9461}, {17.4898, 9398}, {17.1521, 9674}, {17.92, 
    8789}, {18.0992, 8740}, {18.1392, 8549}, {18.5486, 
    8501}, {18.9874, 8727}, {18.9643, 8710}, {18.5903, 
    8681}, {18.6687, 8687}, {17.8913, 8784}, {18.1319, 
    8517}, {18.6675, 8632}, {18.9163, 8868}, {18.2755, 
    8446}, {18.2921, 8541}, {18.629, 8426}, {18.876, 8359}};
Energy2 = 
 SmoothHistogram3D[togather, 
  ScalingFunctions -> {None, None, -Log[#] &}, ImageSize -> Full, 
  ColorFunction -> "TemperatureMap", 
  AxesLabel -> {"Radius Of Gyration(Å)", 
    "Number of Native Contacts", "Energy"}, PlotRange -> All]

3D smooth histogram

What version and platform are you using?

(And on a more semantics note: you are getting the log of the estimated probability density and not the log of the probability.)

Update

The above is simply an attempt to remove the errors you're seeing. But if you really need a set of -Log[density] values, then there are more direct ways to do so. Here is a way that gets you the density values on a grid of x,y values:

(* Estimate a bivariate probability density *)
skd = SmoothKernelDistribution[togather];

(* Make a 100x100 table of estimates of density *)
n = 100;
density = 
  Table[{13 + (22 - 13) i/n, 7000 + (11000 - 7000) j/n, 
   PDF[skd, {13 + (22 - 13) i/n, 7000 + (11000 - 7000) j/n}]}, 
  {i, 0, n}, {j, 0, n}];

(* Plot the results *)
ListPointPlot3D[density, PlotRange -> All]

3D density

You'll need to be wary of density values of zero or very close to zero if you really need -Log[density].

$\endgroup$
1
  • $\begingroup$ ScalingFunctions -> {None, None, -Log[#] &} does not work for me; I have Mathematica 12.0 $\endgroup$ – Valerio Apr 10 '20 at 14:05

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.