I have three parts of a ListPlot3D that I would like to combine. The problem is, the middle part has more points in one dimension than the other two, which means I can't combine them easily to plot them together.

So in the end I have part1 and part3, two 10x10 arrays, and part2, a 10x19 array. How can I plot them together?

Note that the middle part is not wider/longer than the others, it just has more points to account for a more complicated function graph on that region.


1 Answer 1



... the middle part is not wider/longer than the others, it just has more points...

{part1, part3} = RandomInteger[10, {2, 10, 10}];
part2 = RandomInteger[10, {20, 30}];

i = 1;
{lp1, lp2, lp3} = ListPlot3D[#, DataRange -> {{0, 1}, {0, 1}, {0, 10}},
     InterpolationOrder -> 3, PlotStyle -> {Blue, Red, Green}[[i++]], 
     ImageSize -> 300, BoxRatios -> {1, 1, 2/3}] & /@ {part1, part2, part3};
Row[{lp1, lp2, lp3}]

enter image description here

Translate lp2 and lp3 and Show together:

 Graphics3D[GeometricTransformation[lp2[[1]], TranslationTransform[{1, 0, 0}]]],
  Graphics3D[GeometricTransformation[lp3[[1]], TranslationTransform[{2, 0, 0}]]],
  PlotRange -> All, ImageSize -> 500]

enter image description here

Original post:

You can use PadRight to combine the three parts. For example,

{part1, part3} = RandomInteger[10, {2, 5, 5}];
part2 = RandomInteger[10, {5, 12}];
MatrixForm[MatrixForm /@ {part1, part2, part3}]

enter image description here

combined = Join @@ PadRight[{part1, part2, part3}, Automatic, -1];

enter image description here

ListPlot3D[combined, PlotRange -> {0, 10}, InterpolationOrder -> 3, 
 ClippingStyle -> Red, BoxRatios -> {1, 1, 1/2}]

enter image description here

  • $\begingroup$ Thanks for the answer. I guess I should have been clearer about this: the second part is not wider/longer than the others, it just has more points because it is a more complicated curve so more points were necessary to plot it accurately. $\endgroup$
    – tan_45
    Apr 21, 2015 at 17:13
  • $\begingroup$ @tan_45, thank you for the clarification. Could you please update your question posting the data you are using?. $\endgroup$
    – kglr
    Apr 21, 2015 at 17:18
  • $\begingroup$ You've managed to answer perfectly even without my data :) Thanks a lot. $\endgroup$
    – tan_45
    Apr 21, 2015 at 18:02
  • $\begingroup$ @tan_45, my pleasure. Thank you for the accept. $\endgroup$
    – kglr
    Apr 21, 2015 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.