我的 MWE:
\documentclass{scrreprt}
\usepackage{tikz}
\usetikzlibrary{datavisualization.formats.functions}
\pgfooclass{circle visualizer}{%from TikZ & PGF manual, page 928
\attribute name;
\method circle visualizer(#1) {\pgfooset{name}{#1}}
\method default connects() {
\pgfoothis.get handle(\me)
\pgfkeysvalueof{/pgf/data visualization/obj}.connect(\me,visualize,visualize datapoint signal)
}
\method visualize() {
\pgfdvfilterpassedtrue
\pgfdvnamedvisualizerfilter
\ifpgfdvfilterpassed
\dovisualization
\fi
}
}
\def\dovisualization{
\pgfkeysvalueof{/data point/\pgfoovalueof{name}/execute at begin}
\pgfpathcircle{\pgfpointdvdatapoint}{\pgfkeysvalueof{/data point/radius}}
\pgfkeysvalueof{/data point/\pgfoovalueof{name}/execute at end}
}
\tikzdatavisualizationset{
visualize as circle/.style = {
new object = {
when = after survey,
store = /tikz/data visualization/visualizers/#1,
class = circle visualizer,
arg1 = #1
},
new visualizer = {#1}{color = visualizer color,
every path/.style = {
draw,
fill
},
}{},
/data point/set = #1
},
visualize as circle/.default = circle
}
\begin{document}
\begin{figure}
\centering
%pic 1
\begin{tikzpicture}
\datavisualization[
scientific axes = clean,
all axes = grid,
x axis = {unit length = 10em per .5 units},
y axis = {ticks = {node style = {
align = right,
text width = 7.5mm
}
},
label = $\varphi_{\textnormal M1}$ in Grad
},
visualize as line,
every visualizer/.style = very thin
]
data {
x, y
0, -90
.04, -90
.08, -90
.12, -90
.16, -90
.2, -90
.24, -90
.28, -90
.32, -90
.36, -90
.4, -90
.44, -90
.48, -90
.52, -90
.56, -90
.6, -90
.64, -90
.68, -90
.72, -90
.76, -90
.8, -90
.84, -90
.88, -90
.92, -90
.96, -90
1, 90
1.04, 90
1.08, 90
1.12, 90
1.16, 90
1.2, 90
1.24, 90
1.28, 90
1.32, -90
1.36, -90
1.4, -90
1.44, -90
1.48, -90
1.52, -90
1.56, -90
};
\end{tikzpicture}
%pic 2
\begin{tikzpicture}
\datavisualization[
scientific axes = clean,
all axes = grid,
x axis = {unit length = 10em per .5 units},
y axis = {ticks = {node style = {
align = right,
text width = 7.5mm
}
},
label = $\varphi_{\textnormal M2}$ in Grad
},
visualize as line,
every visualizer/.style = very thin
]
data {
x, y
0, 90
.04, 90
.08, 90
.12, -90
.16, -90
.2, -90
.24, -90
.28, -90
.32, 90
.36, 90
.4, 90
.44, 90
.48, 90
.52, -90
.56, -90
.6, -90
.64, -90
.68, -90
.72, -90
.76, -90
.8, 90
.84, 90
.88, 90
.92, 90
.96, 90
1, -90
1.04, -90
1.08, -90
1.12, -90
1.16, -90
1.2, -90
1.24, -90
1.28, -90
1.32, -90
1.36, -90
1.4, -90
1.44, -90
1.48, -90
1.52, 90
1.56, 90
};
\end{tikzpicture}
%pic 3
\begin{tikzpicture}
\datavisualization[
scientific axes = clean,
all axes = grid,
x axis = {unit length = 10em per .5 units},
y axis = {ticks = {node style = {
align = right,
text width = 7.5mm
}
},
label = $\varphi_1$ in Grad
},
visualize as circle
]
data {
x, y, radius
0, 0, .25pt
.04, -.54, .25pt
.08, -.9, .25pt
.12, -2.7, .25pt
.16, -6.3, .25pt
.2, -11.52, .25pt
.24, -17.82, .25pt
.28, -25.2, .25pt
.32, -33.3, .25pt
.36, -41.94, .25pt
.4, -50.58, .25pt
.44, -58.86, .25pt
.48, -66.78, .25pt
.52, -73.98, .25pt
.56, -80.28, .25pt
.6, -85.32, .25pt
.64, -89.46, .25pt
.68, -92.34, .25pt
.72, -94.14, .25pt
.76, -95.04, .25pt
.8, -95.04, .25pt
.84, -94.5, .25pt
.88, -93.6, .25pt
.92, -92.52, .25pt
.96, -91.44, .25pt
1, -90.72, .25pt
1.04, -90.36, .25pt
1.08, -89.82, .25pt
1.12, -88.56, .25pt
1.16, -85.14, .25pt
1.2, -79.02, .25pt
1.24, -70.38, .25pt
1.28, -59.76, .25pt
1.32, -47.34, .25pt
1.36, -33.84, .25pt
1.4, -19.98, .25pt
1.44, -7.2, .25pt
1.48, 2.52, .25pt
1.52, 8.46, .25pt
1.56, 10.26, .25pt
};
\end{tikzpicture}
%pic 4
\begin{tikzpicture}
\datavisualization[
scientific axes = clean,
all axes = grid,
x axis = {unit length = 10em per .5 units},
y axis = {ticks = {node style = {
align = right,
text width = 7.5mm
}
},
label = $\varphi_2$ in Grad
},
visualize as circle
]
data {
x, y, radius
0, 0, .25pt
.04, -.54, .25pt
.08, -.54, .25pt
.12, -.54, .25pt
.16, -.72, .25pt
.2, -.72, .25pt
.24, -.9, .25pt
.28, -1.26, .25pt
.32, -1.8, .25pt
.36, -2.88, .25pt
.4, -4.68, .25pt
.44, -7.2, .25pt
.48, -10.8, .25pt
.52, -15.48, .25pt
.56, -21.24, .25pt
.6, -27.72, .25pt
.64, -34.92, .25pt
.68, -42.3, .25pt
.72, -49.86, .25pt
.76, -57.42, .25pt
.8, -64.8, .25pt
.84, -71.82, .25pt
.88, -78.48, .25pt
.92, -84.6, .25pt
.96, -90.36, .25pt
1, -95.76, .25pt
1.04, -100.62, .25pt
1.08, -104.76, .25pt
1.12, -108.18, .25pt
1.16, -110.7, .25pt
1.2, -111.96, .25pt
1.24, -111.96, .25pt
1.28, -110.52, .25pt
1.32, -107.82, .25pt
1.36, -103.68, .25pt
1.4, -98.28, .25pt
1.44, -91.44, .25pt
1.48, -83.52, .25pt
1.52, -74.52, .25pt
1.56, -64.98, .25pt
};
\end{tikzpicture}
%pic5
\begin{tikzpicture}
\datavisualization[
scientific axes = clean,
all axes = grid,
x axis = {
unit length = 10em per .5 units,
label = $t$ in s
},
y axis = {label = $\varphi_3$ in Grad},
visualize as circle
]
data {
x, y, radius
0, 0, .25pt
.04, -.36, .25pt
.08, -.36, .25pt
.12, .36, .25pt
.16, 2.7, .25pt
.2, 5.94, .25pt
.24, 7.92, .25pt
.28, 7.56, .25pt
.32, 5.04, .25pt
.36, .36, .25pt
.4, -5.22, .25pt
.44, -9.18, .25pt
.48, -10.98, .25pt
.52, -10.62, .25pt
.56, -8.28, .25pt
.6, -5.22, .25pt
.64, -3.96, .25pt
.68, -5.22, .25pt
.72, -9.18, .25pt
.76, -15.48, .25pt
.8, -23.94, .25pt
.84, -34.56, .25pt
.88, -46.8, .25pt
.92, -59.58, .25pt
.96, -70.38, .25pt
1, -77.94, .25pt
1.04, -82.44, .25pt
1.08, -83.52, .25pt
1.12, -82.8, .25pt
1.16, -82.26, .25pt
1.2, -82.62, .25pt
1.24, -83.88, .25pt
1.28, -85.86, .25pt
1.32, -88.56, .25pt
1.36, -91.8, .25pt
1.4, -95.22, .25pt
1.44, -98.46, .25pt
1.48, -101.52, .25pt
1.52, -103.86, .25pt
1.56, -105.3, .25pt
};
\end{tikzpicture}
\end{figure}
\end{document}
创建下图
在你开始之前:对于\begin{tikzpicture}...\end{tikzpicture}
这个问题中的每一个,我都使用真实的\input{path/picNumber.tex}
内容\begin{tikzpicture}...\end{tikzpicture}
。对于这个问题,我使用它只是\begin{tikzpicture}...\end{tikzpicture}
为了更好地理解。
如您所见,x 轴的标签发生了偏移。为什么?仅当我在 x 轴刻度之间引入自定义单位长度时,才会出现这种情况,例如unit length = 10em per .5 units
。我在 x 轴刻度之间使用自定义单位长度来拉伸图形的宽度,因为实际上我有数千个数据点,如果我在 x 轴刻度之间保留标准单位长度,那么我的图形只会变成黑框,因为数据量太大。
如何让移位的标签居中?
提前感谢您的帮助和努力!
答案1
键label={[<options>]<text>}
key 将轴的标签设置为<text>
。此文本将放置在节点内,并且<options
可以使用 > 来配置此节点的呈现方式。您必须说node style
来设置节点的样式。
在此示例中,节点向右移动了10em
,相当于 0.5 个单位,从 0.25 移动到 0.75。
\documentclass{scrreprt}
\usepackage{tikz}
\usetikzlibrary{datavisualization.formats.functions}
\pgfooclass{circle visualizer}{%from TikZ & PGF manual, page 928
\attribute name;
\method circle visualizer(#1) {\pgfooset{name}{#1}}
\method default connects() {
\pgfoothis.get handle(\me)
\pgfkeysvalueof{/pgf/data visualization/obj}.connect(\me,visualize,visualize datapoint signal)
}
\method visualize() {
\pgfdvfilterpassedtrue
\pgfdvnamedvisualizerfilter
\ifpgfdvfilterpassed
\dovisualization
\fi
}
}
\def\dovisualization{
\pgfkeysvalueof{/data point/\pgfoovalueof{name}/execute at begin}
\pgfpathcircle{\pgfpointdvdatapoint}{\pgfkeysvalueof{/data point/radius}}
\pgfkeysvalueof{/data point/\pgfoovalueof{name}/execute at end}
}
\tikzdatavisualizationset{
visualize as circle/.style = {
new object = {
when = after survey,
store = /tikz/data visualization/visualizers/#1,
class = circle visualizer,
arg1 = #1
},
new visualizer = {#1}{color = visualizer color,
every path/.style = {
draw,
fill
},
}{},
/data point/set = #1
},
visualize as circle/.default = circle
}
\begin{document}
\begin{figure}
\centering
%pic 1
\begin{tikzpicture}
\datavisualization[
scientific axes = clean,
all axes = grid,
x axis = {unit length = 10em per .5 units},
y axis = {ticks = {node style = {
align = right,
text width = 7.5mm
}
},
label = $\varphi_{\textnormal M1}$ in Grad
},
visualize as line,
every visualizer/.style = very thin
]
data {
x, y
0, -90
.04, -90
.08, -90
.12, -90
.16, -90
.2, -90
.24, -90
.28, -90
.32, -90
.36, -90
.4, -90
.44, -90
.48, -90
.52, -90
.56, -90
.6, -90
.64, -90
.68, -90
.72, -90
.76, -90
.8, -90
.84, -90
.88, -90
.92, -90
.96, -90
1, 90
1.04, 90
1.08, 90
1.12, 90
1.16, 90
1.2, 90
1.24, 90
1.28, 90
1.32, -90
1.36, -90
1.4, -90
1.44, -90
1.48, -90
1.52, -90
1.56, -90
};
\end{tikzpicture}
%pic 2
\begin{tikzpicture}
\datavisualization[
scientific axes = clean,
all axes = grid,
x axis = {unit length = 10em per .5 units},
y axis = {ticks = {node style = {
align = right,
text width = 7.5mm
}
},
label = $\varphi_{\textnormal M2}$ in Grad
},
visualize as line,
every visualizer/.style = very thin
]
data {
x, y
0, 90
.04, 90
.08, 90
.12, -90
.16, -90
.2, -90
.24, -90
.28, -90
.32, 90
.36, 90
.4, 90
.44, 90
.48, 90
.52, -90
.56, -90
.6, -90
.64, -90
.68, -90
.72, -90
.76, -90
.8, 90
.84, 90
.88, 90
.92, 90
.96, 90
1, -90
1.04, -90
1.08, -90
1.12, -90
1.16, -90
1.2, -90
1.24, -90
1.28, -90
1.32, -90
1.36, -90
1.4, -90
1.44, -90
1.48, -90
1.52, 90
1.56, 90
};
\end{tikzpicture}
%pic 3
\begin{tikzpicture}
\datavisualization[
scientific axes = clean,
all axes = grid,
x axis = {unit length = 10em per .5 units},
y axis = {ticks = {node style = {
align = right,
text width = 7.5mm
}
},
label = $\varphi_1$ in Grad
},
visualize as circle
]
data {
x, y, radius
0, 0, .25pt
.04, -.54, .25pt
.08, -.9, .25pt
.12, -2.7, .25pt
.16, -6.3, .25pt
.2, -11.52, .25pt
.24, -17.82, .25pt
.28, -25.2, .25pt
.32, -33.3, .25pt
.36, -41.94, .25pt
.4, -50.58, .25pt
.44, -58.86, .25pt
.48, -66.78, .25pt
.52, -73.98, .25pt
.56, -80.28, .25pt
.6, -85.32, .25pt
.64, -89.46, .25pt
.68, -92.34, .25pt
.72, -94.14, .25pt
.76, -95.04, .25pt
.8, -95.04, .25pt
.84, -94.5, .25pt
.88, -93.6, .25pt
.92, -92.52, .25pt
.96, -91.44, .25pt
1, -90.72, .25pt
1.04, -90.36, .25pt
1.08, -89.82, .25pt
1.12, -88.56, .25pt
1.16, -85.14, .25pt
1.2, -79.02, .25pt
1.24, -70.38, .25pt
1.28, -59.76, .25pt
1.32, -47.34, .25pt
1.36, -33.84, .25pt
1.4, -19.98, .25pt
1.44, -7.2, .25pt
1.48, 2.52, .25pt
1.52, 8.46, .25pt
1.56, 10.26, .25pt
};
\end{tikzpicture}
%pic 4
\begin{tikzpicture}
\datavisualization[
scientific axes = clean,
all axes = grid,
x axis = {unit length = 10em per .5 units},
y axis = {ticks = {node style = {
align = right,
text width = 7.5mm
}
},
label = $\varphi_2$ in Grad
},
visualize as circle
]
data {
x, y, radius
0, 0, .25pt
.04, -.54, .25pt
.08, -.54, .25pt
.12, -.54, .25pt
.16, -.72, .25pt
.2, -.72, .25pt
.24, -.9, .25pt
.28, -1.26, .25pt
.32, -1.8, .25pt
.36, -2.88, .25pt
.4, -4.68, .25pt
.44, -7.2, .25pt
.48, -10.8, .25pt
.52, -15.48, .25pt
.56, -21.24, .25pt
.6, -27.72, .25pt
.64, -34.92, .25pt
.68, -42.3, .25pt
.72, -49.86, .25pt
.76, -57.42, .25pt
.8, -64.8, .25pt
.84, -71.82, .25pt
.88, -78.48, .25pt
.92, -84.6, .25pt
.96, -90.36, .25pt
1, -95.76, .25pt
1.04, -100.62, .25pt
1.08, -104.76, .25pt
1.12, -108.18, .25pt
1.16, -110.7, .25pt
1.2, -111.96, .25pt
1.24, -111.96, .25pt
1.28, -110.52, .25pt
1.32, -107.82, .25pt
1.36, -103.68, .25pt
1.4, -98.28, .25pt
1.44, -91.44, .25pt
1.48, -83.52, .25pt
1.52, -74.52, .25pt
1.56, -64.98, .25pt
};
\end{tikzpicture}
%pic5
\begin{tikzpicture}
\datavisualization[
scientific axes = clean,
all axes = grid,
x axis = {
unit length = 10em per .5 units,
label={[node style={xshift= 10em}]{$t$ in s}}, %changed <<<<<<<<<<<<<<
},
y axis = {label = $\varphi_3$ in Grad},
visualize as circle
]
data {
x, y, radius
0, 0, .25pt
.04, -.36, .25pt
.08, -.36, .25pt
.12, .36, .25pt
.16, 2.7, .25pt
.2, 5.94, .25pt
.24, 7.92, .25pt
.28, 7.56, .25pt
.32, 5.04, .25pt
.36, .36, .25pt
.4, -5.22, .25pt
.44, -9.18, .25pt
.48, -10.98, .25pt
.52, -10.62, .25pt
.56, -8.28, .25pt
.6, -5.22, .25pt
.64, -3.96, .25pt
.68, -5.22, .25pt
.72, -9.18, .25pt
.76, -15.48, .25pt
.8, -23.94, .25pt
.84, -34.56, .25pt
.88, -46.8, .25pt
.92, -59.58, .25pt
.96, -70.38, .25pt
1, -77.94, .25pt
1.04, -82.44, .25pt
1.08, -83.52, .25pt
1.12, -82.8, .25pt
1.16, -82.26, .25pt
1.2, -82.62, .25pt
1.24, -83.88, .25pt
1.28, -85.86, .25pt
1.32, -88.56, .25pt
1.36, -91.8, .25pt
1.4, -95.22, .25pt
1.44, -98.46, .25pt
1.48, -101.52, .25pt
1.52, -103.86, .25pt
1.56, -105.3, .25pt
};
\end{tikzpicture}
\end{figure}
\end{document}