Quero colocar um gráfico pgfplots ao lado de várias outras imagens PDF que importo para o meu documento, mas não consigo descobrir como posicionar os pgfplots axis
no tamanho maior tikzpicture
:
\documentclass{article}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{figure*}
\begin{center}
\begin{tikzpicture}
\node[anchor=south west] (img) at (0,0)
{\includegraphics[width=0.3\linewidth]{1.pdf}};
\node[anchor=south west]
at (0.01\linewidth,0.01\linewidth) {a};
\node[anchor=south west] (img) at (0.33\linewidth,0)
{\includegraphics[width=0.3\linewidth]{1.pdf}};
\node[anchor=south west]
at (0.34\linewidth,0.01\linewidth) {b};
\begin{axis}[width=0.45\linewidth, yticklabels={}]
\addplot [const plot, fill=red]
table [x index=0, y index=1]
{hist.txt}
\closedcycle;
\end{axis}
\end{tikzpicture}
\end{center}
\caption{\label{detdemo}An example of my output}
\end{figure*}
\end{document}
aqui está o exemplo de saída:
O axis
parece começar a partir (0,0)
do tikzpicture
.
Queria ver como posso posicionar esse eixo depois da segunda foto? De modo que o canto inferior esquerdo esteja ativado (0.66\linewidth,0)
.
Responder1
Você pode definir a coordenada para o canto inferior esquerdo do axis
com a at
tecla,
at={(0.66\linewidth,0)}
Adicione isso às axis
opções.
\documentclass{article}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{figure*}
\begin{center}
\begin{tikzpicture}
\node[anchor=south west] (img) at (0,0)
{\includegraphics[width=0.3\linewidth]{example-image-a}};
\node[anchor=south west]
at (0.01\linewidth,0.01\linewidth) {a};
\node[anchor=south west] (img) at (0.33\linewidth,0)
{\includegraphics[width=0.3\linewidth]{example-image-b}};
\node[anchor=south west]
at (0.34\linewidth,0.01\linewidth) {b};
\begin{axis}[width=0.45\linewidth, yticklabels={},at={(0.66\linewidth,0)}]
\addplot [const plot, fill=red]
{x}
\closedcycle;
\end{axis}
\end{tikzpicture}
\end{center}
\caption{\label{detdemo}An example of my output}
\end{figure*}
\end{document}
Responder2
Como um hack rápido, você pode usar um scope
com um xshift
arquivo .axis
node
\documentclass{article}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure*}
\begin{center}
\begin{tikzpicture}
\node[anchor=south west] (img1) at (0,0)
{\includegraphics[width=0.3\linewidth]{example-image-a}};
\node[anchor=south west]
at (0.01\linewidth,0.01\linewidth) {a};
\node[anchor=south west] (img2) at (0.33\linewidth,0)
{\includegraphics[width=0.3\linewidth]{example-image-b}};
\node[anchor=south west]
at (0.34\linewidth,0.01\linewidth) {b};
\begin{scope}[xshift=0.66\linewidth]
\begin{axis}[width=0.45\linewidth, yticklabels={}]
\addplot [const plot, fill=red]
{x} %% I changed this change it back
\closedcycle;
\end{axis}
\end{scope}
\end{tikzpicture}
\end{center}
\caption{\label{detdemo}An example of my output comes here}
\end{figure*}
\end{document}
Mas será melhor se você usar outro tikzpicture
ambiente IMO.