# Difference in rendering from Matlab2tikz

I have a 3D object produced from Matlab which is like this:

I would like use a vector graphics of the above in my document. However due to the file size, I prefer to save as tikz picture. I used Matlab2tikz for the above picture and got the following one:

I have no concerns about the labels, but can someone help me get the same rendering or a near similar one?

• Can you share the code? Apr 13, 2018 at 12:41
• @samcarter Do you mean the tikz code?
– SKPS
Apr 13, 2018 at 12:49
• Yes, the tikz code. Probably nobody wants to spent ages to recreate it just to change the colours. Apr 13, 2018 at 12:50
• – SKPS
Apr 13, 2018 at 12:53

I cannot post the full code due to length constrictions, but this is what I did:

• removed the first \addplot3
• removed the fill=white!85!black to see the already existing shading
• Use a suitable colour scale for the desired shading

\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{grffile}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows.meta}
\usepgfplotslibrary{patchplots}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=4.895in,
height=5.264in,
at={(4.102in,0.71in)},
scale only axis,
plot box ratio=4 1 1,
xmin=-0.5,
xmax=0.5,
tick align=outside,
ymin=-0.125,
ymax=0.125,
zmin=-0.125,
zmax=0.125,
view={-133.1}{69.2},
axis x line*=bottom,
axis y line*=left,
axis z line*=left
]

surf, z buffer=sort, colormap={my}{
rgb255=(20,20,20)
rgb255=(50,50,50)
rgb255=(250,250,250)
}, mesh/rows=21]
table[row sep=crcr, point meta=\thisrow{c}] {%
%
x   y   z   c\\
-0.5    0   0   0\\
-0.498461042574392  0   0.0195543081300289  0.0195543081300289\\
-0.493882064536894  0   0.0386271242968684  0.0386271242968684\\
...


• That's a strong progress! Can we do something more about the lighting too?
– SKPS
Apr 13, 2018 at 13:05
• @SathishKrishnan You can change it by selecting a suitable colour palette. Apr 13, 2018 at 13:11
• @SathishKrishnan You're welcome! Apr 13, 2018 at 13:45
• Also, please update the code in the pastebin for future users.
– SKPS
Apr 13, 2018 at 13:50
• @SathishKrishnan Ups, I forgot about pastebin. Don't have the code any more. Apr 13, 2018 at 13:52