带有图表、标签、tkiz 和 pgf 的箭头

带有图表、标签、tkiz 和 pgf 的箭头

我想从第一个图表中的 K 画一个箭头到第二个图表 x 标签中的 E。正常箭头可以工作,但轴标签中的节点似乎不起作用。您有什么建议吗?

\documentclass[10pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ucs}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{decorations.text, calc}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

% Commands for Arrows
\newcommand{\VerticalShiftForArrows}{0.0em, -0.5em}
\newcommand{\tikzmark}[2]{%
\tikz[overlay, remember picture] \node[text = black, inner sep = 2pt] (#1) {#2};%
}
\newcommand{\DrawArrow}[3][]{%
    \coordinate (Start Mid) at ($(#2Left)!0.5!(#2Right) + (\VerticalShiftForArrows)$);
    \coordinate (End Mid)   at ($(#3Left)!0.5!(#3Right) + (0em, 1.5em) + (\VerticalShiftForArrows)$);
    \draw[-stealth, thick, #1] (Start Mid) to (End Mid);
}

\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
title = {First Chart},
%title style = {font = \footnotesize},
ybar,
bar width = 5pt,
symbolic x coords={A,B,C,D,E,F,G,H,I,J,\tikzmark{kcLeft}{}K\tikzmark{kcRight}{},L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z},
xtick = data,
%ticklabel style = {font = \tiny},
grid = major,
enlarge y limits = false,
enlarge x limits = 0.025,
height = 0.4\textheight,
width = \textwidth,
]
\addplot coordinates {
(A,0)(B,0)(C,0)(D,0)(E,0)(F,1.887)(G,1.887)(H,0)(I,3.774)(J,3.774)(\tikzmark{kcLeft}{}K\tikzmark{kcRight}{},16.981)(L,0)(M,0)(N,13.208)(O,13.208)(P,0)(Q,0)(R,3.774)(S,5.66)(T,9.434)(U,1.887)(V,5.66)(W,0)(X,1.887)(Y,5.66)(Z,11.321)};  
\end{axis} 
\end{tikzpicture}

\begin{tikzpicture} 
\begin{axis}[
title = {Second Chart},
%title style = {font = \footnotesize},
ybar,
bar width = 5pt,
symbolic x coords={A,B,C,D,\tikzmark{ecLeft}{}E\tikzmark{ecRight}{},F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z},
xtick = data,
%ticklabel style = {font = \tiny},
grid = major,
enlarge y limits = false,
enlarge x limits = 0.025,
height = 0.4\textheight,
width = \textwidth,
]
\addplot coordinates {
(A,6.51)(B,1.89)(C,3.06)(D,5.08)(\tikzmark{ecLeft}{}E\tikzmark{ecRight}{},17.4)(F,1.66)(G,3.01)(H,4.76)(I,7.55)(J,0.27)(K,1.21)(L,3.44)(M,2.53)(N,9.78)(O,2.51)(P,0.79)(Q,0.02)(R,7)(S,7.27)(T,6.15)(U,4.35)(V,0.67)(W,1.89)(X,0.03)(Y,0.04)(Z,1.13)};  
\end{axis} 
\end{tikzpicture}
\end{center}
First character: \tikzmark{kLeft}{}K\tikzmark{kRight}{} \\[2em]
Second character: \tikzmark{eLeft}{}E\tikzmark{eRight}{} \\[2em]
\begin{tikzpicture}[overlay, remember picture]
    \DrawArrow[black, in=90, out=270]{k}{e}
    \DrawArrow[black, in=90, out=270]{kc}{ec}
\end{tikzpicture}
\end{document}

不工作示例的图片

相关内容