# ContourPlot3D not wotking for slicing z axis in the ranges of 10^-13

I am using ContourPlot3D to obtain a slice plane at z = constant. However I find that the plane's position is not moving when the range is of the order of 10^-13. I am using the following code.

zSlice = ContourPlot3D[z == -6*10^-13, {x, 0, 3*10^-6}, {y, -2, 2}, {z, -8*10^-13,2*10^-13}, ContourStyle -> Opacity[0.5, Lighter@Green],Mesh -> None,ImageSize -> Large, PlotRange -> {-8*10^-13, 2*10^-13}]
zSlice = ContourPlot3D[z == -4*10^-13, {x, 0, 3*10^-6}, {y, -2, 2}, {z, -8*10^-13,2*10^-13}, ContourStyle -> Opacity[0.5, Lighter@Green],Mesh -> None,ImageSize -> Large, PlotRange -> {-8*10^-13, 2*10^-13}]


The above code doesn't change the z=constant plane in the plot. What could be the error?

In general, it is a bad idea to work with really small or really large parameters in expressions that you then use in plots or equations. Instead you should re-scale your quantities into an appropriate system of units. For example, in atomic systems you should use atomic units. The wikipedia entry on nondimensionalization is a good introduction.

Also, I see that you have manually typed in epsilon = 8.85*10^-12, which I assume is the permittivity of free space. Note that Mathematica has built-in access to the current value of physical constants. And this quantity now has an exact value:

WolframAlphaResult["permittivity of free space", {{"Definition", 1}, "Content"},
PodStates -> {"Value__Show exact value"}]


I'd bet that if you re-scale your parameters, all the problems you are experiencing will disappear and also your plots will look more elegant as the ticks will be numbers of order 1.

• Thank you. Yes, I re-scaled my values and hence I am able to get the planes cutting the axis and also able to move this plane with good precision. Thanks for your input on physical constants. Jun 21, 2019 at 4:35

To avoid possible precision issues, you can rescale the contour levels and vertical plot range to run from -8 to 2 (say) and use custom ticks for the vertical axis to show the scaled-back tick labels:

ContourPlot3D[{z == -6, z == -4}, {x, 0, 3*10^-6}, {y, -2, 2}, {z, -8,
2},
ContourStyle -> {Opacity[0.5, Lighter@Green],  Opacity[0.5, Lighter@Red]},
Mesh -> None, ImageSize -> Medium,
PlotRange -> {-8, 2},
Ticks -> {Automatic, Automatic, ChartingFindTicks[{-8, 2}, (10^-13) {-8, 2}][-8, 2]}]


Update: to combine with another Plot3D output you can rescale the first argument of Plot3D and use zSlice4 first in Show (so that the option values of zlice3D for ticks is in effect in Show):

fig1 = Plot3D[Sin[x + y^2] 10^12, {x, -5*10^-12, 2*10^-12}, {y, 0, 2*10^-12}];
zSlice4 = ContourPlot3D[{z == -3, z == -2}, {x, -5*10^-12, 2*10^-12},
{y, 0, 2*10^-12}, {z, -5, 2},
ContourStyle -> {Opacity[0.5, Lighter@Green], Opacity[0.5, Lighter@Red]},
Mesh -> None, ImageSize -> Large,
PlotRange -> {-5, 2},
Ticks -> {Automatic, Automatic, ChartingFindTicks[{-5, 2}, (10^-12) {-5, 2}][-5, 2]}];

Show[zSlice4, fig1]


• Thanks for your reply. However, I need to add this to another Plot3D using Show[] command. But I am facing an error there. Please see the code snippet below: fig1 = Plot3D[Sin[x + y^2], {x, -5*10^-12, 2*10^-12}, {y, 0, 2*10^-12},ImageSize -> Large] zSlice4 = ContourPlot3D[{z == -3}, {x, -5*10^-12, 2*10^-12}, {y, 0,2*10^-12}, {z, -5, 2},ContourStyle -> {Opacity[0.5, Lighter@Green], Opacity[0.5, Lighter@Red]}, Mesh -> None, ImageSize -> Large,PlotRange -> {-5, 2},Ticks -> {Automatic, Automatic,ChartingFindTicks[{-5, 2}, (10^-12) {-5, 2}][-5, 2]}] Show[fig1, zSlice4] Thanks in advance. Jun 4, 2019 at 10:46
• Thank you. But I still face a problem in the output plot I am getting using this ticks. The output x axis is protruding beyond the specified limit. k = 0.439; epsilon = 8.85*10^-12; A = 960*10^-12; g = 3*10^-6; m = 4.4736*10^-12; V = 13; Jun 5, 2019 at 4:29
• @Raghuram, i suggest you update your question with that example showing what roles k, epsilon, A,g and V play in Plot3D and ContourPlot3D.
– kglr
Jun 5, 2019 at 4:35
• Yes I have updated the question. Sorry for missing the complete code snippet. Jun 5, 2019 at 4:57
• @Raghuram, you updated your deleted answer; you should put that information in the question, not in a deleted answer.
– kglr
Jun 5, 2019 at 4:59

My Plot3D now is a surface rather than a plane. When I did as you mentioned, I am able to see only the top surface of my plot and not the entire surface. So I changed my Plot3D also with ticks command. But I am now facing an error that my output plot is protruding beyond the x range specified. Pls see the code snippet below.

k = 0.439; epsilon = 8.85*10^-12; A = 960*10^-12; g = 3*10^-6; m = 4.4736*10^-12; V = 13;
MyOut[x_, xdot_] := 0.5*m*xdot^2   + 0.5*k*x^2 - (0.5*epsilon*A*V^2)/(g - x);
fig1 = Plot3D[MyOut[x, xdot]*10^12, {x, 0, g}, {xdot, -2, 2},
AxesLabel -> {x,xdot,MyOutput}, ImageSize -> Large,
PlotRange -> {-5, 2},
Ticks -> {Automatic, Automatic,
ChartingFindTicks[{-5, 2}, (10^-12) {-5, 2}][-5, 2]}];
zSlice4 =
ContourPlot3D[{z == -1}, {x, 0, g}, {y, -2, 2}, {z, -5, 2},
ContourStyle -> {Opacity[0.5, Lighter@Green],
Opacity[0.5, Lighter@Red]}, Mesh -> None, ImageSize -> Large,
PlotRange -> {-5, 2},
Ticks -> {Automatic, Automatic,
ChartingFindTicks[{-5, 2}, (10^-12) {-5, 2}][-5, 2]}];
Show[zSlice4, fig1]

• scaling factor 10^-12 was for the specific case fig1 = Plot3D[Sin[x + y^2], {x, -5*10^-12, 2*10^-12}, {y, 0, 2*10^-12},ImageSize -> Large]  in your comment. For the new function MyOut you need to find the scaling factor based on the range of xdot and x`
– kglr
Jun 5, 2019 at 5:48
• Ok. Thanks a lot. Jun 5, 2019 at 7:23