我试图在我的图表上绘制一条水平线.线的Y坐标应位于点a和b之间(a在b下方).该行的左右端点位于tikzpicture的边界框上.以下是我现在使用交集运算符执行此操作的方法:
\coordinate (h0) at ($(a.north)!0.5!(b.south)$); \draw (h0 -| current bounding box.west) -- (h0 -| current bounding box.east);
这让我感到非常迂回.我宁愿做的是得到(h0)的Y坐标和边界框的东边和西边的X坐标,并自己编写坐标.我想这样做,但不支持语法:
\coordinate (h0) at ($(a.north)!0.5!(b.south)$); \draw (current bounding box.west.x,h0.y) -- (current bounding box.east.x,h0.y);
有没有办法引用我遗漏的坐标的各个组成部分?
Rup*_*ash 18
您可以获取操作中的组件let
.在PGF手册中查找作品,但是从内存中:
\draw
let
\p1=($(a.north)!0.5!(b.south)$),
\p2=(current bounding box.west),
\p3=(current bounding box.east)
in
(\x2,\y1) -- (\x3, \y1);
Run Code Online (Sandbox Code Playgroud)
那可能需要调试......编辑:现在感谢提问者了.
或者,使用
\pgfextractx{<dimension>}{<point>}
\pgfextracty{<dimension>}{<point>}
Run Code Online (Sandbox Code Playgroud)
这些是原始PGF命令,因此使用它们可能不太方便.
我刚刚从中找到的另一个选项表明,您可以通过执行以下操作从节点获取相对定位:
\node at (2, 1) (a) {};
\draw (a) -- ++(right:2);
Run Code Online (Sandbox Code Playgroud)
这将从节点 a 到点 a 右侧 2 个单位的点绘制一条线。就像我链接的示例一样,当您不知道节点的确切坐标并且需要绘制相对于它的事物时,这非常有用。
归档时间: |
|
查看次数: |
12353 次 |
最近记录: |