Plot3D Not Showing plot - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-09-18T14:28:18Z https://mathematica.stackexchange.com/feeds/question/47984 https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/47984 0 Plot3D Not Showing plot Andrew Ross https://mathematica.stackexchange.com/users/14411 2014-05-16T19:16:18Z 2014-05-17T02:10:52Z <p>I have a function that I'm trying to visualize and for some reason the plot only shows a small snippet of the graph of the function. The function, <code>d</code>, and relevant values are as follows:</p> <pre><code> G = 6.67*10^(-11) c = 3*10^8 M = 10^(30) J = 10^(20) \[Gamma] = 0.018 rmin = M + Sqrt[M^2 - J^2/M^2] d[r_, \[Theta]_] = 1 - (2 G M r)/(c^2 r^2 + J^2/M^2 Cos[\[Theta]]^2) - (Sin[\[Theta]]^2 \[Gamma]^2)/c^2 (r^2 + J^2/(M^2 c^2) + ( 2 G J^2 r Sin[\[Theta]]^2)/(c^4 M (r^2 + J^2/(M^2 c^2) Cos[\[Theta]]^2))) + (8 \[Gamma] G r J Sin[\[Theta]]^2)/(c^4 (r^2 + J^2/(M^2 c^2) Cos[\[Theta]]^2)) </code></pre> <p>The exact values of <code>\[Gamma], M</code> and <code>J</code> aren't particularly significant, although <code>M</code> and <code>J</code> are meant to be large. I'm trying to plot the graph of this function using Plot3D</p> <pre><code> Plot3D[ d[Sqrt[x^2 + y^2], ArcCos[x/Sqrt[x^2 + y^2]]], {x, 0, 3 M}, {y,0, 6 M}, RegionFunction -&gt; Function[{x, y, z}, rmin &lt; Sqrt[x^2 + y^2] ] ] </code></pre> <p>I'm really new when it comes to working with mathematica, but I've seen online that sometimes varying <code>PlotPoints</code> and <code>MaxRecursion</code> can help to fix a plot. I tried setting <code>PlotPoints -&gt; {50, 100, 1000}</code>, as well as <code>MaxRecursion -&gt; 10</code> (I don't if these values are high or low w.r.t Mathematica's default settings), changing these tended to make Mathematica really sluggish, moreover they didn't produce any more of the plot. I've also tried setting <code>ClippingStyle -&gt; None</code> and <code>PlotRange -&gt; All</code> and none of these had any effect. </p> <p>I'm thinking that maybe It could be the large values that might be throwing Mathematica off, but I was under the impression that Mathematica could deal with 'astronomical numbers' (literally). Anyway if anybody has any insight into what's going wrong or just helpful advice it would be very much appreciated. </p> <p><strong>EDIT</strong>: In the comments it was mentioned that (0,0) is a potential problem, but I have an analogous function </p> <pre><code> M = 10 J = 1 \[Gamma] = 0.018 g[r_, \[Theta]_] = 1 - 2 M r/(r^2 + J^2/M^2 Cos[\[Theta]]^2) - \[Gamma]^2 Sin[\[Theta]]^2 (r^2 + J^2/M^2 + 2 r J^2 Sin[\[Theta]]^2/(M (r^2 + J^2/M^2 Cos[\[Theta]]^2))) + \[Gamma] 8 r J Sin[\[Theta]]^2/(r^2 + J^2/M^2 Cos[\[Theta]]^2) </code></pre> <p>Which in principle is the same, and should encounter the same issue at (0,0), but Plot3D manages just fine.</p> https://mathematica.stackexchange.com/questions/47984/plot3d-not-showing-plot/47993#47993 2 Answer by george2079 for Plot3D Not Showing plot george2079 https://mathematica.stackexchange.com/users/2079 2014-05-16T20:58:30Z 2014-05-17T02:10:52Z <p>It is simply an issue with the extreme plot range:</p> <pre><code> typical = With[{y = 6 M , x = 3 M}, d[Sqrt[x^2 + y^2], ArcCos[x/Sqrt[x^2 + y^2]]]] </code></pre> <blockquote> <p>-1.296*10^41</p> </blockquote> <pre><code> Plot3D[d[Sqrt[x^2 + y^2], ArcCos[x/Sqrt[x^2 + y^2]]]/typical, {x, 0, 3 M}, {y, 0, 6 M}] </code></pre> <p><img src="https://i.stack.imgur.com/JuVWK.png" alt="enter image description here"></p> <p>put the proper tics on the axis, and using your <code>RegionFunction</code>:</p> <pre><code> Plot3D[d[Sqrt[x^2 + y^2], ArcCos[x/Sqrt[x^2 + y^2]]]/typical, {x, 0,3 M}, {y, 0, 6 M} , RegionFunction -&gt; Function[{x, y, z}, rmin &lt; Sqrt[x^2 + y^2]], Ticks -&gt; {Automatic, Automatic, Table[-i 10^41 {1/typical , 1}, {i, 0, 1.5, .25}]}] </code></pre> <p><img src="https://i.stack.imgur.com/3IzA5.png" alt="enter image description here"></p> <p>Likewise the jagginess on the hole left by the regionfunction is cleaned up by normalizing the x,y ranges:</p> <pre><code> sx = 1. 10^30; Plot3D[d[sx Sqrt[x^2 + y^2], ArcCos[x/Sqrt[( x)^2 + ( y)^2]]]/typical, {x, 0, 3 }, {y, 0, 6} , RegionFunction -&gt; Function[{x, y, z}, rmin/sx &lt; Sqrt[x^2 + y^2]], Ticks -&gt; {Table[{i, i sx}, {i, 0, 3}], Table[{i, i sx}, {i, 0, 6}], Table[-i 10^41 {1/typical, 1}, {i, 0, 1.5, .25}]}] </code></pre> <p><img src="https://i.stack.imgur.com/MC1Js.png" alt="enter image description here"></p>