I am trying to include a tikzpicture inside a figure. It had worked for other tikzpicture, but now I have a complicated 3D one here, that I have trouble integrating.
Here is the overleaf MWE where you can run and see the error (sorry, thats only way I could find to show error)
Error is pretty generic and cryptic as usual like "undefined control sequence". I dont understand, why tikzpicture as outside works fine, but when put inside figure suddenly not. As you could also see, I need to be inside figure float else you can see its improperly placed.
Front code:
\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{mytikz_custom}
\pgfplotsset{compat=1.15}
\author{Parthiban Rajendran}
\begin{document}
% example 3D sample set
\pgfplotstableread{
X Y Z m
2.2 14 0 0
2.7 23 0 0
3 13 0 0
3.55 22 0 0
4 15 0 0
4.5 20 0 0
4.75 28 0 0
5.5 23 0 0
}\datatablet
\section{Runs fine if not inside figure}
\begin{tikzpicture}[scale=1.5]
\begin{axis}
[ set layers,
view={130}{50},
samples=200,
samples y=0,
xmin=1,xmax=6, ymin=5,ymax=40, zmin=0, zmax=10,
% ytick=\empty,xtick=\empty,ztick=\empty,
clip=false, axis lines = middle,
area plot/.style= % for this: https://tex.stackexchange.com/questions/53794/plotting-several-2d-functions-in-a-3d-graph
{
fill opacity=0.5,
draw=none,
fill=orange,
mark=none,
smooth
}
]
\GetLocalFrame
\begin{scope}[transform shape]
\addplot3[only marks, fill=cyan,mark=fcirc] table {\datatablet};
\end{scope}
\end{axis}
\end{tikzpicture}
\section{Silly blocking error if put inside figure}
The error says undefined control sequence. Commented to go through. Same tikz content as above, only now inside figure.
\begin{figure}
\begin{tikzpicture}[scale=1.5]
\begin{axis}
[ set layers,
view={130}{50},
samples=200,
samples y=0,
xmin=1,xmax=6, ymin=5,ymax=40, zmin=0, zmax=10,
% ytick=\empty,xtick=\empty,ztick=\empty,
clip=false, axis lines = middle,
area plot/.style= % for this: https://tex.stackexchange.com/questions/53794/plotting-several-2d-functions-in-a-3d-graph
{
fill opacity=0.5,
draw=none,
fill=orange,
mark=none,
smooth
}
]
\GetLocalFrame
\begin{scope}[transform shape]
\addplot3[only marks, fill=cyan,mark=fcirc] table {\datatablet};
\end{scope}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
And here is the style package mytikz_custom
\GetLocalFrameadd\globaldefs=0\relaxafter\tikzset. (I guess I need to rewrite this bit, didn't expect you'd use it like that.) – Oct 22 '18 at 17:36