I have the following data:

bData = {{0.05, 0, 3.0198054316361485}, {0.05, 0.55, 
 1.1092237487369552}, {0.05, 1., 0.835126287487935}, {0.05, 1.61, 
 0.3647962208597364}, {0.1, 0, 2.991741037155516}, {0.1, 0.55, 
 1.1270688044265789}, {0.1, 1., 0.8493688576645464}, {0.1, 1.61, 
 0.5932718812318991}, {0.15, 0, 2.8183386248853517}, {0.15, 0.55, 
 1.6096377385996246}, {0.15, 1., 1.1088595437185633}, {0.15, 1.61, 

I plot my data as follows:

p1 = ListPointPlot3D[bData, PlotStyle -> PointSize[Large]]
p2 = ListPlot3D[bData, MeshStyle -> Red, PlotStyle -> None, 
  Mesh -> All, InterpolationOrder -> 1(*,ClippingStyle\[Rule]None*), 
  PlotRange -> All]
Show[{p1, p2}]

What I want to achieve with this is to show the data points clearly and also connect them in the x and y direction with simple lines.

I have done the following


Output 2

Output 3

I would like to remove all the diagonal lines and just connect the points in the x and y directions.

If I do Mesh->Full, I get the following:

Output 4

Is there also a way of marking the vertices, without having to superpose two different plots? That complicates the labelling and legending I also want.

  • 1
    $\begingroup$ Why do you have InterpolationOrder->10 if all you want are the lines connecting the data points? $\endgroup$
    – Michael E2
    Mar 6, 2013 at 1:00
  • $\begingroup$ No, it was just a mistake I did when I copied it, because I was playing with that number before, but actually it doesn't change the output of my question above. $\endgroup$
    – Santiago
    Mar 6, 2013 at 6:56

3 Answers 3


You can add the mesh specific to the x and y coordinates of your data with Mesh -> {First /@ bData, #[[2]] & /@ bData}:

p1 = ListPointPlot3D[bData, PlotStyle -> PointSize[Large]]
p2 = ListPlot3D[bData, MeshStyle -> Red, PlotStyle -> None, 
    Mesh -> {First /@ bData, #[[2]] & /@ bData}, 
    InterpolationOrder -> 10(*,ClippingStyle->None*), PlotRange -> All]
Show[{p1, p2}]

Mathematica graphics


Just saw the added requirement for labels so need to comply before @VLC (who beat me to the answer by some seconds) sees it :)

You can add labels to your points like so:

labels = Graphics3D[
    Text[ToString@Round[#, .1], #, {-1.5, 1.5}]] & /@ bData;

the first slot within Text is what you see (so I round it to the first decimal point so that it doesn't look too crammed), the second is the actual coordinates for the placement of the text, and the third is an offset so as not to fall on the points. Now


Mathematica graphics

I don't know how you can avoid making one plot for the mesh and one for the points. In 2d Graphics, you'd normally add the points as an epilog to ListPlot so that they show over your lines but in 3d graphics I don't think you can do this.

  • $\begingroup$ Nice labelling. Good answer, I just have to practice a bit more how to write code with short forms. $\endgroup$
    – Santiago
    Mar 5, 2013 at 20:39

With your data you could try to specify the divisions of the Mesh to match your x and y coordinates:

p1 = ListPointPlot3D[bData, PlotStyle -> PointSize[Large]];
p2 = ListPlot3D[bData, MeshStyle -> Red, PlotStyle -> None, 
  Mesh -> {Union[bData[[All, 1]]], Union[bData[[All, 2]]]}, 
  InterpolationOrder -> 10, PlotRange -> All];

enter image description here

  • $\begingroup$ Really simple solution, nice $\endgroup$
    – Santiago
    Mar 6, 2013 at 16:16

ListPlot3D generates output of the form Graphics3D[GraphicsComplex[pts, g,...] so you can insert the points manually like this:

p = ListPlot3D[bData, MeshStyle -> Red, PlotStyle -> None, 
  Mesh -> {Union[bData[[All, 1]]], Union[bData[[All, 2]]]},(*InterpolationOrder\[Rule]10,*)
  PlotRange -> All];
Insert[p, {ColorData[1][1], PointSize[Large], Point[Range[Length[bData]]], 
  Table[Text[bData[[i, 3]], i, {0, -1.3}], {i, Length[bData]}]}, {1, 2, -1}]

Mesh with points

Alternately, if the structure of bData is the same as the example (sorted by $x$ and then by $y$ coordinates, forming a grid) and all you want are the mesh lines, one can simply partition the data and draw the lines as follows:

xLines = Partition[bData, 4];
yLines = Transpose[xLines];
Graphics3D[{{Red, Line[xLines~Join~yLines]},
  ColorData[1][1], PointSize[Large], Point[bData], 
  Table[Text[bData[[i, 3]], bData[[i]], {0, -1.3}], {i, Length[bData]}]},
 BoxRatios -> {1, 1, 0.4}, Axes -> True, ImagePadding -> Scaled[0.05]]

The output is the same as above.

  • $\begingroup$ Thanks for the nice and different approach, anyway I will take the other question, since it's more understandble for me at this point. $\endgroup$
    – Santiago
    Mar 6, 2013 at 16:15
  • 1
    $\begingroup$ @Santi You're welcome. The other answers seem good, and you should accept the one that seems best to you. Each answer gives someone with a similar question to yours choices for which solution works best or can be adapted to their case. In comparing answers I often learn something new about Mathematica. $\endgroup$
    – Michael E2
    Mar 6, 2013 at 17:18

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.