# How to configure axis using characters and draw graphs? (tikzpicture)

I am new to LateX and want to draw a graph with letters on my Y-axis and values on my X-axis.Unfortunately it is not working as expected. I would like to have all values (A to Z) on my Y-axis and the values [0,100] on my X-axis.

My code:

\documentclass[12pt]{article}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
ytick=data,
yticklabels={,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,
U,V,W,X,Y,Z},
height=16cm,
xtick={0,10,20,30,40,50,60,80,80,90,100},
width =12cm
]

%Graph: y=B
%\addplot[blue, ultra thick] (B); not working
%Graph: x=40
%Draw Value (50,C)
\end{axis}
\end{tikzpicture}

\end{document}


results in the following output:

How do I draw values like (50,C) and functions like y=B in my graph?

• Welcome to TeX.SX! Please provide a compilable document, not just a fragment. – Bobyandbob Jan 27 '18 at 0:44
• thanks for the info! I completed the fragment to a runnable code. :-) – BPdone Jan 27 '18 at 0:54
• {A,...,Z} is supported – percusse Jan 27 '18 at 1:23
• Where do I find documentation on this? @percusse – BPdone Jan 27 '18 at 10:55
• The ... syntax is documented in chapter 83 Repeating things: the foreach statement of the manual for pgf/TikZ. It does not work in symbolic y coords (cf. my answer) though, there you must specify the coordinates explicitly. – Torbjørn T. Jan 29 '18 at 10:35

Assuming that this is some sort of fun question, here comes a fun answer. You may use the \InvAlph function which, as indicated by its name, is the inverse of \Alph.

\documentclass{article}
\usepackage{pgfplots}
\def\numA{1}
\def\numB{2}
\def\numC{3}
\def\numD{4}
\def\numE{5}
\def\numF{6}
\def\numG{7}
\def\numH{8}
\def\numI{9}
\def\numJ{10}
\def\numK{11}
\def\numL{12}
\def\numM{13}
\def\numN{14}
\def\numO{15}
\def\numP{16}
\def\numQ{17}
\def\numR{18}
\def\numS{19}
\def\numT{20}
\def\numU{21}
\def\numV{22}
\def\numW{23}
\def\numX{24}
\def\numY{25}
\def\numZ{26}
\newcommand{\InvAlph}[1]{\csname num#1\endcsname}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
ytick={0,1,..., 26},
yticklabels={,A,...,Z},
height=16cm,
xtick={0,10,20,30,40,50,60,80,80,90,100},
width =12cm
]
\end{axis}
\end{tikzpicture}
\end{document}


Notice that this is a fun answer. The definition of \InvAlph is clumsy and, more importantly, fragile, i.e. it returns an error if you feed it with something different from A,... Z.

• Well, besides the fact you did not respect my concern. The x-axis is still not giving 10,20,...,100 but 0, 0.2, 0.4,...1 - bad answer – BPdone Jan 27 '18 at 11:09
• @BPdone It is. Don't make false accusations. In this fun answer, I just pot short stretches such that this is not seen. – marmot Jan 27 '18 at 14:38

Your requirements are not entirely clear to me, but it sounds like you might want to have a look at symbolic y coords:

\documentclass[12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
symbolic y coords={A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,
U,V,W,X,Y,Z},
% symbolic coords have a numeric distance of 1
ytick distance=1,
xtick={0,10,...,100},
height=16cm,
width =12cm,
xmin=0,xmax=100,
% in order to set limits for a symbolic axis, we need [normalized]
ymin={[normalized] 0},
ymax={[normalized] 25}
]

%Graph: y=B