Skip to content

Instantly share code, notes, and snippets.

@sharethewisdom
Created June 14, 2019 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharethewisdom/f53e967474d4ea70d1f7e0e26b015b11 to your computer and use it in GitHub Desktop.
Save sharethewisdom/f53e967474d4ea70d1f7e0e26b015b11 to your computer and use it in GitHub Desktop.
\documentclass[border=5mm]{standalone}
\usepackage{filecontents}
\begin{filecontents*}{A0.txt}
x y ey- ey+ label
21 -26 {} {} A0
33 -25 {} {} A1
40 -23 2 2 E2
45 -19.5 2.5 2 A2
49 -14 1 1 C\sharp3
52 -13 1 1.5 E3
55 -7 {} {} G3
57 -3 {} {} {}
59 3 {} {} B3
61 7 {} {} C\sharp4
63 14 {} {} E\flat4
64 19 {} {} E4
65 25 {} {} F4
66 33 {} {} F\sharp4
66.3 38 {} {} {}%dummy
66.6 43 {} {} {}%dummy
\end{filecontents*}
\begin{filecontents*}{A1.txt}
x y ey- ey+ label
33 -6 {} {} A1
45 -5 {} {} {}
52 -3.5 {} {} E3
57 -3 {} {} {}
61 -2 {} {} C\sharp4
64 -1 {} {} E4
67 1 {} {} G4
69 2 {} {} A4
71 4 {} {} B4
73 6 {} {} C\sharp5
75 9 {} {} D\sharp5
76 11 {} {} E5
77 14 {} {} {}%dummy
79 22 {} {} {}%dummy
\end{filecontents*}
\begin{filecontents*}{A2.txt}
x y ey- ey+ label
45 -2 {} {} A2
57 -1.4 {} {} {}
64 -1 {} {} E4
69 -1 {} {} {}
73 -.8 {} {} {}
76 -.6 {} {} {}
79 0 {} {} {}
81 1 {} {} {}
83 2.5 {} {} B5
85 4.5 {} {} C\sharp6
87 6.5 {} {} D\sharp6
89 9 {} {} F6
92 14 {} {} {}%dummy
94 21 {} {} {}%dummy
\end{filecontents*}
\begin{filecontents*}{A3.txt}
x y ey- ey+ label
57 -1.4 {} {} A3
69 -1 {} {} {}
76 -.5 {} {} {}
81 1 {} {} {}
85 3 {} {} {}
88 5.2 {} {} {}
91 8.6 {} {} G6
93 12 {} {} A6
95 16 {} {} {}% dummy
97 21 {} {} {}% dummy
\end{filecontents*}
\begin{filecontents*}{A4.txt}
x y ey- ey+ label
69 0 {} {} {}
81 .5 {} {} {}
88 5 {} {} {}
93 12 {} {} {}
96 18 {} {} {}
97 20.5 {} {} {}% dummy
99 26 {} {} {}% dummy
\end{filecontents*}
\begin{filecontents*}{A5.txt}
x y ey- ey+ label
81 1.2 {} {} {}
93 12 {} {} {}
100 26 {} {} E7
105 39 {} {} A7
106 42 {} {} {}% dummy
108 50 {} {} {}% dummy
\end{filecontents*}
\begin{filecontents*}{A6.txt}
x y ey- ey+ label
93 12 {} {} {}
105 39 {} {} {}
107.4 48 {} {} {}% dummy
108.2 54 {} {} {}% dummy
\end{filecontents*}
\begin{filecontents*}{A7.txt}
x y ey- ey+ label
105 39 {} {} {}
107 48 {} {} {}% dummy
108 58 {} {} {}% dummy
\end{filecontents*}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usetikzlibrary{arrows.meta,plotmarks,decorations.markings,intersections}
\tikzset{%
every pin/.style={black,fill=white,rectangle,outer sep=1pt,inner sep=1pt, rounded corners=3pt,font=\tiny}%
,n/.style={xshift=-1ex,yshift=1em,font=\bfseries}
,key/.style={scale=1.4,line width=.4pt,line cap=round}
,x/.pic={\draw[key,fill=black,xshift=#1] (0.5pt,-13pt) -- (0pt, -12.5pt) -- (0pt, 0pt) -- (2.5pt, 0pt) -- (2.5pt, -12.5pt) -- (2pt, -13pt) -- cycle;}
,g/.pic={\draw[key,fill=gray,xshift=-1.6pt] (0pt,-20pt) -- (0pt, -14pt) -- (0.4pt, -14pt) -- (0.4pt, 0pt) -- (3.8pt, 0pt) -- (3.8pt, -14pt) -- (5.2pt, -14pt) -- (5.2pt, -20pt) -- cycle;}
,a/.pic={\draw[key,fill=darkgray,xshift=-2.6pt] (0pt,-20pt) -- (0pt, -14pt) -- (1.4pt, -14pt) -- (1.4pt, 0pt) -- (4.8pt, 0pt) -- (4.8pt, -14pt) -- (5.2pt, -14pt) -- (5.2pt, -20pt) -- cycle;}
,d/.pic={\draw[key,fill=gray,xshift=-2.1pt] (0pt,-20pt) -- (0pt, -14pt) -- (0.7pt, -14pt) -- (0.7pt, 0pt) -- (4.5pt, 0pt) -- (4.5pt, -14pt) -- (5.2pt, -14pt) -- (5.2pt, -20pt) -- cycle;}
,b/.pic={\draw[key,fill=gray,xshift=-3.6pt] (0pt,-20pt) -- (0pt, -14pt) -- (2.1pt, -14pt) -- (2.1pt, 0pt) -- (5.2pt, 0pt) -- (5.2pt, -20pt) -- cycle;}
,e/.pic={\draw[key,fill=gray,xshift=-3.2pt] (0pt,-20pt) -- (0pt, -14pt) -- (2.1pt, -14pt) -- (2.1pt, 0pt) -- (5.2pt, 0pt) -- (5.2pt, -20pt) -- cycle;}
,c/.pic={\draw[key,fill=gray,xshift=-1.1pt] (0pt,-20pt) -- (0pt, 0pt) -- (3.1pt, 0pt) -- (3.1pt, -14pt) -- (5.2pt, -14pt) -- (5.2pt, -20pt) -- cycle;}
,f/.pic={\draw[key,fill=gray,xshift=-0.6pt] (0pt,-20pt) -- (0pt, 0pt) -- (3pt, 0pt) -- (3pt, -14pt) -- (5.2pt, -14pt) -- (5.2pt, -20pt) -- cycle;}
}
\pgfplotsset{%
width=16cm%
,height=7cm%
,scale only axis%
,compat=1.15%
,major grid style={dotted,thin,gray}
,tick label style={font=\small}
,tickwidth=0pt
,nodes near coords style={font=\tiny,yshift=-2pt}
,nodes near coords align={anchor=south east}
,label style={font=\small}
,axis x line=bottom
,axis y line=left
}
\begin{document}
\begin{tikzpicture}[baseline,pin distance=4ex]
\begin{axis}[%
name=main plot
,clip=false
,xtick={21,33,...,105},
,xticklabels={A0, A1, A2, A3, A4, A5, A6, A7},
,ylabel={Deviation (cents)}
,ytick={-25,-20,...,45}
,ymin=-34
,ymax=50
,xmin=17.5
,xmax=108
,grid=major
,major grid style={black!50}
,axis y discontinuity=crunch
,enlargelimits=false
,scatter/@pre marker code/.code={
\pgfmathtruncatemacro{\lasttwomarks}{%
or((\coordindex==(\numcoords-2)), (\coordindex==(\numcoords-1)))%
}
\ifnum\lasttwomarks=1
\def\markopts{mark=none}
\else
\def\markopts{mark=*,mark size=1pt}
\fi
\ifnum\coordindex=0
\def\markopts{mark=*,fill=white,mark size=2pt}
\fi
\expandafter\scope\expandafter[\markopts]
}
,scatter/@post marker code/.code={
\endscope
}
]
% visualization depends on={value \thisrow{label}\as\mylabel}, nodes near coords = {\mylabel{}},
\addplot[%
scatter%
,color=blue%
,smooth%
,-Stealth%
,point meta=explicit symbolic%
,nodes near coords*={\tiny\ensuremath{\pgfplotspointmeta}}%
,error bars/.cd%
,y dir=both%
,y explicit
,error bar style={-}
] table [%
meta=label%
,y error plus=ey+%
,y error minus=ey-%
] {A0.txt};
% coordinate [pos=1] (A0);
% \draw [-Stealth,color=blue] (A0) -- ++(3pt, 20pt); %9+400
\addplot[%
scatter%
,color=black%
,smooth%
,-Stealth%
,point meta=explicit symbolic%
,nodes near coords*={\tiny\ensuremath{\pgfplotspointmeta}}%
,error bars/.cd%
,y dir=both%
,y explicit
,error bar style={-}
] table [%
meta=label%
,y error plus=ey+%
,y error minus=ey-%
] {A1.txt};
% coordinate [pos=1] (A1);
% \draw [-Stealth,color=black] (A1) -- ++(12pt, 17pt);
\addplot[%
scatter%
,color=cyan%
,smooth%
,-Stealth%
,point meta=explicit symbolic%
,nodes near coords*={\tiny\ensuremath{\pgfplotspointmeta}}%
,error bars/.cd%
,y dir=both%
,y explicit
,error bar style={-}
] table [%
meta=label%
,y error plus=ey+%
,y error minus=ey-%
] {A2.txt};
% coordinate [pos=1] (A2);
% \draw [-Stealth,color=cyan] (A2) -- ++(14pt, 16pt);
\addplot[%
scatter%
,color=darkgray%
,smooth%
,-Stealth%
,point meta=explicit symbolic%
,nodes near coords*={\tiny\ensuremath{\pgfplotspointmeta}}%
,error bars/.cd%
,y dir=both%
,y explicit
,error bar style={-}
] table [%
meta=label%
,y error plus=ey+%
,y error minus=ey-%
] {A3.txt};
% coordinate [pos=1] (A3);
% \draw [-Stealth,color=darkgray] (A3) -- ++(14pt, 16pt);
\addplot[%
scatter%
,color=purple%
,smooth%
,-Stealth%
,point meta=explicit symbolic%
,nodes near coords*={\tiny\ensuremath{\pgfplotspointmeta}}%
,error bars/.cd%
,y dir=both%
,y explicit
,error bar style={-}
] table [%
meta=label%
,y error plus=ey+%
,y error minus=ey-%
] {A4.txt};
% coordinate [pos=1] (A4);
% \draw [-Stealth,color=purple] (A4) -- ++(13pt, 17pt);
\addplot[%
scatter%
,color=orange%
,smooth%
,-Stealth%
,point meta=explicit symbolic%
,nodes near coords*={\tiny\ensuremath{\pgfplotspointmeta}}%
,error bars/.cd%
,y dir=both%
,y explicit
,error bar style={-}
] table [%
meta=label%
,y error plus=ey+%
,y error minus=ey-%
] {A5.txt};
% coordinate [pos=1] (A5);
% \draw [-Stealth,color=orange] (A5) -- ++(12pt, 17pt);
\addplot[%
scatter%
,color=teal%
,smooth%
,-Stealth%
,point meta=explicit symbolic%
,nodes near coords*={\tiny\ensuremath{\pgfplotspointmeta}}%
,error bars/.cd%
,y dir=both%
,y explicit
,error bar style={-}
] table [%
meta=label%
,y error plus=ey+%
,y error minus=ey-%
] {A6.txt};
% \draw[teal,{Circle[fill=white]}-Stealth] (axis cs:93,12)
% to[out=35, in=240] (axis cs:105, 39) to[out=60, in=250] (axis cs:108, 54);
\addplot[%
scatter%
,color=gray%
,smooth%
,-Stealth%
,point meta=explicit symbolic%
,nodes near coords*={\tiny\ensuremath{\pgfplotspointmeta}}%
,error bars/.cd%
,y dir=both%
,y explicit
,error bar style={-}
] table [%
meta=label%
,y error plus=ey+%
,y error minus=ey-%
] {A7.txt};
% \draw[gray,{Circle[fill=white]}-Stealth] (axis cs:105, 39)
% to[out=60, in=250] (axis cs:109, 58);
\pic at (axis cs:17, -40) {f};
\pic at (axis cs:18, -40) {x=-0.7pt};
\pic at (axis cs:19, -40) {g};
\pic at (axis cs:20, -40) {x=-0.8pt};
\pic at (axis cs:21, -40) {a};
\pic at (axis cs:22, -40) {x=-0.9pt};
\pic at (axis cs:23, -40) {b};
\pic at (axis cs:24, -40) {c};
\pic at (axis cs:25, -40) {x=-1pt};
\pic at (axis cs:26, -40) {d};
\pic at (axis cs:27, -40) {x=-0.6pt};
\pic at (axis cs:28, -40) {e};
\pic at (axis cs:29, -40) {f};
\pic at (axis cs:30, -40) {x=-0.7pt};
\pic at (axis cs:31, -40) {g};
\pic at (axis cs:32, -40) {x=-0.8pt};
\pic at (axis cs:33, -40) {a};
\pic at (axis cs:34, -40) {x=-0.9pt};
\pic at (axis cs:35, -40) {b};
\pic at (axis cs:36, -40) {c};
\pic at (axis cs:37, -40) {x=-1pt};
\pic at (axis cs:38, -40) {d};
\pic at (axis cs:39, -40) {x=-0.6pt};
\pic at (axis cs:40, -40) {e};
\pic at (axis cs:41, -40) {f};
\pic at (axis cs:42, -40) {x=-0.7pt};
\pic at (axis cs:43, -40) {g};
\pic at (axis cs:44, -40) {x=-0.8pt};
\pic at (axis cs:45, -40) {a};
\pic at (axis cs:46, -40) {x=-0.9pt};
\pic at (axis cs:47, -40) {b};
\pic at (axis cs:48, -40) {c};
\pic at (axis cs:49, -40) {x=-1pt};
\pic at (axis cs:50, -40) {d};
\pic at (axis cs:51, -40) {x=-0.6pt};
\pic at (axis cs:52, -40) {e};
\pic at (axis cs:53, -40) {f};
\pic at (axis cs:54, -40) {x=-0.6pt};
\pic at (axis cs:55, -40) {g};
\pic at (axis cs:56, -40) {x=-0.7pt};
\pic at (axis cs:57, -40) {a};
\pic at (axis cs:58, -40) {x=-0.8pt};
\pic at (axis cs:59, -40) {b};
\pic at (axis cs:60, -40) {c};
\pic at (axis cs:61, -40) {x=-1pt};
\pic at (axis cs:62, -40) {d};
\pic at (axis cs:63, -40) {x=-0.6pt};
\pic at (axis cs:64, -40) {e};
\pic at (axis cs:65, -40) {f};
\pic at (axis cs:66, -40) {x=-0.7pt};
\pic at (axis cs:67, -40) {g};
\pic at (axis cs:68, -40) {x=-0.8pt};
\pic at (axis cs:69, -40) {a};
\pic at (axis cs:70, -40) {x=-0.9pt};
\pic at (axis cs:71, -40) {b};
\pic at (axis cs:72, -40) {c};
\pic at (axis cs:73, -40) {x=-1pt};
\pic at (axis cs:74, -40) {d};
\pic at (axis cs:75, -40) {x=-0.6pt};
\pic at (axis cs:76, -40) {e};
\pic at (axis cs:77, -40) {f};
\pic at (axis cs:78, -40) {x=-0.7pt};
\pic at (axis cs:79, -40) {g};
\pic at (axis cs:80, -40) {x=-0.8pt};
\pic at (axis cs:81, -40) {a};
\pic at (axis cs:82, -40) {x=-0.9pt};
\pic at (axis cs:83, -40) {b};
\pic at (axis cs:84, -40) {c};
\pic at (axis cs:85, -40) {x=-1pt};
\pic at (axis cs:86, -40) {d};
\pic at (axis cs:87, -40) {x=-0.6pt};
\pic at (axis cs:88, -40) {e};
\pic at (axis cs:89, -40) {f};
\pic at (axis cs:90, -40) {x=-0.7pt};
\pic at (axis cs:91, -40) {g};
\pic at (axis cs:92, -40) {x=-0.8pt};
\pic at (axis cs:93, -40) {a};
\pic at (axis cs:94, -40) {x=-0.9pt};
\pic at (axis cs:95, -40) {b};
\pic at (axis cs:96, -40) {c};
\pic at (axis cs:97, -40) {x=-1pt};
\pic at (axis cs:98, -40) {d};
\pic at (axis cs:99, -40) {x=-0.6pt};
\pic at (axis cs:100, -40) {e};
\pic at (axis cs:101, -40) {f};
\pic at (axis cs:102, -40) {x=-0.7pt};
\pic at (axis cs:103, -40) {g};
\pic at (axis cs:104, -40) {x=-0.8pt};
\pic at (axis cs:105, -40) {a};
\pic at (axis cs:106, -40) {x=-0.9pt};
\pic at (axis cs:107, -40) {b};
\end{axis}
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment