# Hexagonal meshing in Plot3D

How can I include hexagonal meshing on a Plot3D such as this?

Plot3D[Sin[x], {z, -3, 3}, {x, -4 \[Pi], 4 \[Pi]}]

• You may be able to use the answers from here: mathematica.stackexchange.com/q/39879/9490 Jan 23, 2018 at 18:37
• I saw that, but I couldn't use that because that was used for graphic plot 3d and my plot is not graphic plot
– some
Jan 23, 2018 at 18:49
• I think its fair to say there is not a straightforward way to do this for a general function. Jan 23, 2018 at 20:48
• This is a step in the right direction: pastebin.com/raw/NtSmn50x , based off the answer here: mathematica.stackexchange.com/q/77312/9490 Jan 23, 2018 at 20:59

Using rm-rf's hextile yet again

hexTile[n_, m_] := With[{hex = Polygon[Table[{Cos[2 Pi k/6] + #, Sin[2 Pi k/6] + #2},
{k, 6}]] &}, Table[hex[3 i + 3 ((-1)^j + 1)/4, Sqrt[3]/2 j], {i, n}, {j, m}] /.
{x_?NumericQ, y_?NumericQ} :> 2 π {x/(3 m), 2 y/(n Sqrt[3])}

ClearAll[plot3DwHexMesh]
plot3DwHexMesh[f_, n_: 20, m_: 20, s_: Yellow, o : OptionsPattern[]] :=
Graphics3D[hexTile[n, m] /. Polygon[l_] :>
{s, Polygon[l], Polygon[{Pi/5, 0} + {-1, 1} # & /@ l]} /.
Polygon[l_List] :> Polygon[{#, #2, f[#, #2]} & @@@ l], o,
Axes -> False, PlotRange -> All, Lighting -> "Neutral"]


Examples:

plot3DwHexMesh[Sin[#] &]


plot3DwHexMesh[Sin[# + #2] &, 20, 20,
Directive[Orange, Opacity[0.8], Specularity[White, 30]],  Boxed -> False]


• The problem with this, and every variant I tried using hexTile, is that I couldn't find a way to respect the original PlotRange. plot3DwHexMesh should, ultimately, take the x and y range into consideration, and show the Axes with the correct values. Jan 23, 2018 at 21:32
• @JasonB, right; I was puzzling over exactly those challenges. Not easy. Hence False as the default option value for Axes:)
– kglr
Jan 23, 2018 at 21:40