There is likely a very simple solution, but I have been unable to find it.

I am using Mathematica 10.4 and wish to combine a parametric plot with a 3d vector.

Suppose I have a 3D vector drawn by

test1 = Graphics3D[{Arrow[{{1/10, 3/Sqrt[
      10], -(Sqrt[(5/2)]/3)}, {-3 Sqrt[2/5], 1, 0}}]}, Axes -> True, 
  AxesLabel -> {x, u, t}, BoxRatios -> {1, 1, 1}]

and a parametric plot given by

test2 = ParametricPlot3D[{x, Sqrt[1 - x], 0.1/x}, {x, 0, 1}, 
  AxesLabel -> {x, u, t}, BoxRatios -> {1, 1, 1}, 
  PlotRange -> {{0, 1}, {0, 1}, {0, 1}}]

These yield the desired plots.

However, when I combine them with the code

Show[test1, test2]

I get the following imageenter image description here

I thought using Plotrange would help, but it doesn't seem to make any difference.

  • $\begingroup$ Using PlotRange seems to help for me, Show[test1, test2, PlotRange -> {{-2, 1}, {0, 1}, {-.6, 1}}] gives me this $\endgroup$ – Jason B. Jul 12 '16 at 13:45
  • $\begingroup$ @Kuba - I don't really think this is a duplicate of that one, since changing the order in Show makes the arrow invisible. I think it could possibly be a "Simple Mistake" close since giving PlotRange to Show fixes the problem. But I do think there's some buggy behavior here that isn't explained by the accepted answer - just look at the insane plotrange choses by the Show in the OP - or compare the results of Charting`get3DPlotRange /@ {test1, test2, Show[test1, test2], Show[test2, test1]} $\endgroup$ – Jason B. Jul 12 '16 at 13:57
  • $\begingroup$ @JasonB you are right, I was too hasty. $\endgroup$ – Kuba Jul 12 '16 at 14:00

Or just keep the original definitions of test1 and test2 and use the PlotRange option:

Show[test1, test2, PlotRange -> Automatic]

Mathematica graphics

Why is Automatic not the default option? I'm not sure.

Why does the default PlotRange result in an insane range for the 3rd coordinate?

Charting`get3DPlotRange@Show[test1, test2]
(* {{-1.95773, 1.06036}, {-0.0206875, 1.02083}, {-102084., 
  5.00208*10^6}} *)

well that seems like a bug to me...

  • $\begingroup$ I restarted Mathematica and the PlotRange works fine (not sure what the issue was); that was a mistake on my part. However, it is strange that the plot range didn't default to that. $\endgroup$ – zalba19 Jul 12 '16 at 14:23

The options given to the final Graphics3D object are generally taken to be those specified in the first object passed to Show. In This case, you didn't specify an explicit PlotRange argument in test1, and that specified in test2 is not used, so that Mathematica chooses it automatically.

You will notice that just changing the order of the arguments of Show, using Show[test2, test1], the blow up goes away, as in this case the PlotRange of the final plot is taken to be that explicitly specified in test2.

Ultimately, the blow up is due to the fact that plotting the whole of test2 does indeed result in a plot with that scale, as you check with Show[test2, PlotRange -> All].

Using your original code, without changing the order of the arguments of Show, you can avoid the scaling issue of the arrowhead by giving explicitly its size:

test1 = Graphics3D[{
      {1/10, 3/Sqrt[10], -(Sqrt[(5/2)]/3)}, {-3 Sqrt[2/5], 1, 0}
   Axes -> True,
   AxesLabel -> {x, u, t},
   BoxRatios -> {1, 1, 1}
test2 = ParametricPlot3D[
   {x, Sqrt[1 - x], 0.1/x}, {x, 0, 1},
   AxesLabel -> {x, u, t},
   BoxRatios -> {1, 1, 1},
   PlotRange -> {{0, 1}, {0, 1}, {0, 1}}
Show[test1, test2]
  • $\begingroup$ Interesting. Thank you for the swift reply. All works as expected. Thank you $\endgroup$ – zalba19 Jul 12 '16 at 13:53

Try this:

    test1 = Graphics3D[{ 
    Arrow[{{1/10, 3/Sqrt[10], -(Sqrt[(5/2)]/3)}, {-3 Sqrt[2/5], 1, 

test2 = ParametricPlot3D[{x, Sqrt[1 - x], 0.1/x}, {x, 0, 1}, 
   BoxRatios -> {1, 1, 1}, PlotRange -> {{-2, 1}, {-1, 1}, {-0.5, 1}},
    AxesLabel -> {x, u, t}];

Show[{test2, test1}]

yielding this:

enter image description here


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.