我正在尝试用 中的特征向量和特征值制作椭圆tikz
。我很难管理我的牙套。我想知道是否有任何分析方法来调整牙套。谢谢
\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{shapes.geometric}
\pgfplotsset{compat=1.7}
\begin{document}
\begin{tikzpicture}
\draw[rotate=45, line width = 0.5mm] (0, 0) ellipse (4.5cm and 2.0cm);
\draw[line width = 0.5mm, dashed, ->] (-5, 0) -- (5, 0) node[right]{$X_{1}$};
\draw[line width = 0.5mm, dashed, ->] (0, -5) -- (0, 5) node[above]{$X_{2}$};
\draw[line width = 0.5mm, ->] (-4, -4) -- (4, 4) node[above right]{$e_1$};
\draw[line width = 0.5mm, ->] (3, -3) -- (-4, 4) node[above left]{$e_2$};
\draw [decorate, decoration = {brace, amplitude = 15pt, mirror, raise =4pt}, yshift = 0pt]
(3, 3.2) -- (0, 0) node [black, midway, xshift = -0.5cm, yshift = 0.8cm ] {$\frac{c}{\sqrt{\lambda_1}}$};
\draw [decorate, decoration = {brace, amplitude = 15pt, mirror, raise =4pt}, yshift = 0pt]
(-1.4, 1.4) -- (0, 0) node [black, midway, xshift = -0.9cm, yshift = -0.3cm ] {$\frac{c}{\sqrt{\lambda_2}}$};
\end{tikzpicture}
\end{document}
答案1
您已加载pgfplots
包,尽管你没有使用它。我已将其删除,并只加载了 TikZ(在本例中通过类选项tikz
)。
使用样式!
我介绍了几个。它们是:
elli=<angle>:<x radius> and <y radius>
该
elli
风格导致节点呈椭圆形,按指定半径旋转<angle>
。该样式还用于
outer sep=0pt
将锚点移动到线的中间。elli node=<angle>
该
elli node
样式应该用于括号的节点(特征值?)。未绘制形状圆形用于更精确地放置节点。这通过两种方式完成:锚点设置为
<angle>-90
,以便节点与装饰线呈矩形放置。节点向相反方向移动,
<angle>+90
移动的量为amplitude
和raise
量(raise
量不存储在像amplitude
量这样的宏中,因此我手动将其存储在 中,并添加了/pgf/decoration/raise
)。
看一下这个动画,了解如何覆盖锚点以替换节点(我将其用于是特征值)。无论如何,可能还需要使用 TikZ 的移位选项。
eigen={<amplitude>}{<raise>}
amplitude
此样式使用给定的和选项值进行所有括号raise
。默认值为15pt
和4pt
(如您的示例所示)。风格
axis
应该normal axis
是不言自明的。
注释(进一步增强)
如果您有更合适的名称,请重命名样式,
eigenvalue
例如说 而不是elli node
。我现在注意到,
mirror
在放置时没有考虑该选项elli node
。这意味着节点始终放置在左侧。这可以很容易地修复。我使用椭圆节点的锚点来绘制线条埃1和埃2.我不太确定线条应该有多长。这只是相对于另一个对象放置线条的众多选项之一。
正常的轴不会被触及(除了样式)。
代码
\documentclass[tikz]{standalone}
\usetikzlibrary{
shapes.geometric,
decorations.pathreplacing
}
\tikzset{
elli/.style args={#1:#2and#3}{
draw,
shape=ellipse,
rotate=#1,
minimum width=2*#2,
minimum height=2*#3,
outer sep=0pt,
},
/pgf/decoration/raise/.append code={
\def\tikzdecorationsbrace{#1}
},
elli node/.style={
circle,
black,
draw=none,
midway,
anchor=#1-90,
inner sep=0pt,
shift=(#1+90:\tikzdecorationsbrace+\pgfdecorationsegmentamplitude)
},
eigen/.style 2 args={
decorate,
decoration={
brace,
amplitude=#1,
mirror,
raise=#2,
},
},
eigen/.default={15pt}{4pt},
axis/.style={
line width=.5mm,
->,
},
normal axis/.style={
axis,
dashed,
}
}
\begin{document}
\begin{tikzpicture}
\node[elli=45:4.5cm and 2.0cm, line width = 0.5mm] at (0, 0) (e) {};
\draw[normal axis] (-5, 0) -- (5, 0) node[right] {$X_{1}$};
\draw[normal axis] (0, -5) -- (0, 5) node[above] {$X_{2}$};
\draw[axis] ([shift={(45:-5.5cm)}] e.center) -- ([shift={(45:5.5cm)}] e.center) node[above right] {$e_1$};
\draw[axis] ([shift={(90+45:-5.5cm)}] e.center) -- ([shift={(90+45:5.5cm)}] e.center) node[above left] {$e_2$};
\draw[red,eigen] (e.east) -- (e.center)
node[elli node=45] {$\frac{c}{\sqrt{\lambda_1}}$};
\draw[red,eigen] (e.north) -- (e.center)
node[elli node=45+90, anchor=-15] {$\frac{c}{\sqrt{\lambda_2}}$};
\end{tikzpicture}
\end{document}
输出
答案2
您应该使用scope
环境来绘制所有将旋转的东西,并放置非旋转文本的坐标。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\begin{scope}[remember picture,rotate=45]
\coordinate (O) at (0,0);
\coordinate (A) at (4.5,0);
\coordinate (B) at (0,2);
% draw ellipse
\draw[line width = 0.5mm] (O) ellipse (4.5cm and 2.0cm);
% draw axis
\draw[line width = 0.5mm, ->] (-5, 0) -- (5, 0) coordinate[right] (e1);
\draw[line width = 0.5mm, ->] (0, -5) -- (0, 5) coordinate[above] (e2);
% calculate brace points for major axis
\path (O) -- (A) coordinate[pos=.02] (a1) coordinate[pos=.98] (a2);
\draw[decorate, decoration = {brace, amplitude = 15pt, mirror, raise =4pt}, yshift = 0pt]
(a2) -- (a1) coordinate[midway] (tl1);
\coordinate (l1) at ([yshift=1cm]tl1);
% calculate brace points for minor axis
\path (O) -- (B) coordinate[pos=.05] (b1) coordinate[pos=.95] (b2);
\draw[decorate, decoration = {brace, amplitude = 15pt, mirror, raise =4pt}, yshift = 0pt]
(b2) -- (b1) coordinate[midway] (tl2);
\coordinate (l2) at ([xshift=-.9cm]tl2);
\end{scope}
\draw[line width = 0.5mm, dashed, ->] (-5, 0) -- (5, 0) node[right]{$X_{1}$};
\draw[line width = 0.5mm, dashed, ->] (0, -5) -- (0, 5) node[above]{$X_{2}$};
\node[anchor=south west] at (e1) {$e_1$};
\node[anchor=south east] at (e2) {$e_2$};
\node[anchor=south west] at (l1) {$\frac{c}{\sqrt{\lambda_1}}$};
\node[anchor=south east] at ([xshift=.1cm]l2) {$\frac{c}{\sqrt{\lambda_2}}$};
\end{tikzpicture}
\end{document}
编辑:根据建议进行修改
答案3
\documentclass[pstricks,border=3pt]{standalone}
\usepackage{pst-plot,pst-node,amsmath}
\pstVerb
{
/PtCm {72.27 div 2.54 mul} def
/Radius 11 def
}
\psset
{
dimen=middle,
nodesep=2pt,
linearc=5pt,
arm=4pt,
}
\begin{document}
\begin{pspicture}(-3.75,-3.75)(4,4)
\psaxes[labels=none,ticks=none,arrowinset=0,linestyle=dashed]{->}(0,0)(-3.75,-3.75)(3.25,3.5)[$X_1$,0][$X_2$,90]
\rput{45}(0,0){
\psaxes[labels=none,ticks=none,arrowinset=0]{->}(0,0)(-3.5,-3.5)(3.5,3.5)
[{\rput{*0}(5pt,0){$e_1$}},0]
[{\rput{*0}(0,5pt){$e_2$}},90]
\psellipse[dimen=middle](0,0)(3,1.5)
\psset{linecolor=gray,angleA=90,angleB=270}
\pcdiag(0,0)(1.5,12pt)
\pcdiag(3,0)(1.5,12pt)
\rput{*0}(!Radius PtCm 100 PtoC exch 1.5 add exch 12 PtCm add){$\tfrac{c}{\sqrt{\lambda_1}}$}
\psset{angleA=180,angleB=0}
\pcdiag(0,1.5)(-12pt,0.75)
\pcdiag(0,0)(-12pt,0.75)
\rput*{*0}(!Radius PtCm 200 PtoC exch 12 PtCm sub exch 0.75 add){$\tfrac{c}{\sqrt{\lambda_2}}$}
}
\end{pspicture}
\end{document}