I have following code:
\documentclass{article}
\usepackage{tikz,amsmath}
\usepackage{subfig}
\usepackage{pgfplots}
\begin{document}
\begin{figure}[!t]
\centering
\subfloat[A space-filling Latin Hypercube Design]{\label{fig_space_fill}
\begin{tikzpicture}[scale=0.45, font = \scriptsize]%
%\begin{axis}[
\draw[step=1cm,black,thin] (0,0) grid (5,5);
\foreach \xtick in {0,...,5} {\pgfmathsetmacro\result{\xtick * .2} \node at (\xtick,-0.5) {\pgfmathprintnumber{\result}}; },
\foreach \ytick in {0,...,5} {\pgfmathsetmacro\result{\ytick * .2} \node at (-.5,\ytick) {\pgfmathprintnumber{\result}}; },
%xticklabel style={
%rotate=90,
%},
%]
\foreach \x/\y in {.5/2.5, 1.5/.5, 2.5/4.5, 3.5/1.5, 4.5/3.5}{\draw [fill=black, thin] (\x,\y) circle [radius=0.05];},
\node at (2.5,-1) {$x1$};
\node at (-1.3,2.5) {$x2$};
%\end{axis}
\end{tikzpicture}%
}
\qquad
\subfloat[A non-space-filling Latin Hypercube Design]{\label{fig_no_space_fill}
\begin{tikzpicture}[scale=0.45, font = \scriptsize]%
%\begin{axis}[
\draw[step=1cm,black,thin] (0,0) grid (5,5);
\foreach \xtick in {0,...,5} {\pgfmathsetmacro\result{\xtick * .2} \node at (\xtick,-0.5) {\pgfmathprintnumber{\result}}; },
\foreach \ytick in {0,...,5} {\pgfmathsetmacro\result{\ytick * .2} \node at (-.5,\ytick) {\pgfmathprintnumber{\result}}; },
%xticklabel style={
%rotate=90,
%},
%]
\foreach \x/\y in {.5/.5, 1.5/1.5, 2.5/2.5, 3.5/3.5, 4.5/4.5}{\draw [fill=black, thin] (\x,\y) circle [radius=0.05];}
\node at (2.5,-1) {$x1$};
\node at (-1.3,2.5) {$x2$};
%\end{axis}
\end{tikzpicture}%
}
\caption{Two instances of Latin Hypercube Design}
\label{space_filling}
\end{figure}
\end{document}
I am trying to rotate the xtick labels (0, 0.2, 0.4,…,1). I tried using axis
environment with:
xticklabel style={
rotate=90,
},
But my code hangs every time. I am not sure what's wrong.
Any help will be appreciated. Thanks.
Best Answer
I have redone your graphs with
pgfplots
. I think you will appreciate the shorter and easier code.Output
Code