答案1
看看,如果以下修改鲍勃·鲍勃答案满足你的期望:
\documentclass[tikz, border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[
dot/.style = {circle, fill=black,inner sep=0pt, minimum size=4pt},
every label/.append style = {inner sep=0pt, rotate around={45:(-0.5,1.5)}},
thick
]
\draw ( 0,0.2) -- + (0,-0.4) node[below] {HIGH};
\draw (10,0.2) -- + (0,-0.4) node[below] {LOW};
%
\draw[thick] (0,0) -- node[below=2mm] {X axis titel} + (10,0);
%
\foreach \p in {0.1, 0.2, 0.5, 0.9}
{
\node[dot,label={Example $=\p$}] at (10*\p,0) {};
}
\end{tikzpicture}
\end{document}
附录:
如果标签的宽度不同,则需要为每个标签分别计算旋转枢轴。枢轴坐标的确定分为两个步骤:第一步是测量标签的长度,第二步是从节点坐标计算旋转枢轴所需的位移(偏移):
\documentclass[tikz, border=3mm]{standalone}
\newlength\LabelWidth
\begin{document}
\begin{tikzpicture}[
set text to width of/.code = {% code for the label length measurement
\pgfmathsetlength\LabelWidth{width("#1")}%
\pgfkeysalso{text width=\the\LabelWidth}% define label text width
},
dot/.style = {circle, fill=black, inner sep=0pt, minimum size=4pt,
label={[set text to width of=#1,
shift={(0.707*\LabelWidth/2+1em,0.707*\LabelWidth/2)},
rotate=45,
inner sep=0pt,
]above:{#1}
},
},
thick
]
\draw ( 0,0.2) -- + (0,-0.4) node[below] {HIGH};
\draw (10,0.2) -- + (0,-0.4) node[below] {LOW};
%
\draw[thick] (0,0) -- node[below=2mm] {X axis titel} + (10,0);
%
\foreach \p in {0.1, 0.222222222, 0.55, 0.9}
{
\node[dot=Example {$=\p$}] at (10*\p,0) {};
}
\end{tikzpicture}
\end{document}
注意:计算枢轴偏移时必须考虑旋转角度:x 方向为 ~ \cos(angle),y 方向为 ~ \sin(angle)。
答案2
这里简单尝试一下:
您可以使用...控制定位,
distance=<lenght>
并将角度更改75:
为 90 度,...或其他角度....也可以使用... anchor
=south、xshift
=1cm、yshift
=-1cm...
\documentclass[tikz, border=30pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=6]
\draw[thick] (1.1,0.05)--(1.1,-0.05) node[anchor=north] {HIGH};
\draw[thick] (0,0.05)--(0,-0.05) node[anchor=north] {LOW};
\node [draw=none] at (0.5,-0.1) {X axis titel} ;
\draw[thick] (0,0)--(1.1,0);
\foreach \Point in {0.1, 0.2, 0.5, 0.9}{
\node[label={[label distance=1mm]75:\rotatebox{45}{Example x= \Point}}] at (\Point,0) {\textbullet};
}
\end{tikzpicture}
\end{document}