Hi
I am trying to draw a plot like below. This is working fine in actual tex file
But when I try to use the same in ipython tikzmagic, this is what I get
MWE for tex file:
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
% \usetikzlibrary{math, decorations.pathreplacing,angles,quotes,bending}
\pgfplotsset{compat=1.15}
\pgfplotstableread{
X Y label
2.2 14 $(x_1,y_1)$
2.7 23 $(x_2,y_2)$
2.4 12 $(x_3,y_3)$
1.5 19 $(x_4,y_4)$
}\datatable
\begin{document}
\section{table using raw data}
% https://tex.stackexchange.com/questions/11251/trend-line-or-line-of-best-fit-in-pgfplots
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
% legend pos=outer north east,
xmin=1,xmax=4,ymin=5,ymax=30,
ytick=\empty,xtick=\empty,
xlabel={x},ylabel={y},
clip=false, axis on top,grid = major,axis lines = middle,
every node near coord/.append style={anchor=south west},
]
\addplot [nodes near coords, only marks, blue, mark = *, point meta = explicit symbolic, font=\fontsize{5pt}{5pt}\selectfont] table[meta = label] {\datatable};
\coordinate (XYA) at (2.2, 14);
\coordinate (XYB) at (2.7, 23);
\coordinate (XYC) at (2.4, 12);
\coordinate (XYD) at (1.5, 19);
\draw [ultra thin, draw=green, fill=green, opacity=0.2] (XYA) rectangle (XYB);
\draw [ultra thin, draw=red, fill=red, opacity=0.2] (XYC) rectangle (XYD);
\end{axis}
\end{tikzpicture}
\end{document}
MWE for tikzmagic which goes in a ipython cell:
%%tikz -p pgfplots
\pgfplotstableread{
X Y label
2.2 14 $(x_1,y_1)$
2.7 23 $(x_2,y_2)$
2.4 12 $(x_3,y_3)$
1.5 19 $(x_4,y_4)$
}\datatable
\begin{axis}[
xmin=1,xmax=4,ymin=5,ymax=30,
ytick=\empty,xtick=\empty,
xlabel={x},ylabel={y},
clip=false, axis on top,grid = major,axis lines = middle,
every node near coord/.append style={anchor=south west}
]
\addplot [nodes near coords, only marks, blue, mark = *, point meta = explicit symbolic] table[meta = label] {\datatable};
\coordinate (XYA) at (2.2, 14);
\coordinate (XYB) at (2.7, 23);
\coordinate (XYC) at (2.4, 12);
\coordinate (XYD) at (1.5, 19);
\draw (0,0) rectangle (10,10);
\draw [draw=green, fill=green] (2.2,14) rectangle (2.7,23);
\draw [ultra thin, draw=red, fill=red, opacity=0.5] (XYC) rectangle (XYD);
\end{axis}
I initially had tried to push the datatable to preamble, but in that case, I get error as tikzmagic not able to reference that datatable so included in same cell now.
Kindly help with why the draw coordinates mess up? I even tried passing hard coded coordinate value but same issue as see in MWE.
Hi I am trying to draw a plot like below. This is working fine in actual tex file
But when I try to use the same in ipython tikzmagic, this is what I get![2018-10-29_19h54_13](https://user-images.githubusercontent.com/11896263/47656102-7054c500-dbb4-11e8-8e74-d2c1cb0ebc49.png)
MWE for tex file:
MWE for tikzmagic which goes in a ipython cell:
I initially had tried to push the datatable to preamble, but in that case, I get error as tikzmagic not able to reference that datatable so included in same cell now.
Kindly help with why the draw coordinates mess up? I even tried passing hard coded coordinate value but same issue as see in MWE.