我有以下代码:
\begin{tikzpicture}[scale=0.6]
\draw[thick,<->] (0,14) node[above]--(0,0)--(14,0) node[right];
\draw[thick,-] (0,-1) node[above]--(0,0)--(-1,0) node[right];
\draw[very thick, green, domain=0:14] plot (\x,7);
\draw (2.3,-0.5) node[label=below: x] {};
\draw (7,-0.5) node[label=below: y] {};
\draw (11.7,-0.5) node[label=below: u] {};
\draw[color=green] (7,8.5) node[label=below: Constant] {};
\draw (3,-2.7) node[label=below: Low] {};
\draw (10,-2.7) node[label=below: High] {};
\end{tikzpicture}
还有两个问题:
- 我想在 y 轴上添加旋转文本。我试过了,
\draw[rotate=90]…
但没有效果。 - 我怎样才能复制该图并并排显示两个图?
答案1
像这样:
代码:
\documentclass[a4paper]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[scale=.7]
% grid and axis
\draw[gray!15] (-6,-6) grid (6,6);
\draw[line width=.5pt,-latex] (-6,0)--(6,0) node[right] () {\small $x$};
\draw[line width=.5pt,-latex] (0,-6)--(0,6) node[above] () {\small $y$};
\foreach \i in {-6,-5,...,-1,1,2,...,5}{
\draw[thick] (\i,0)--(\i,-.05) node[below] () {\footnotesize \bfseries \i} ;
\draw[thick] (0,\i)--(-.05,\i) node[left] () {\footnotesize \bfseries \i} ;
\node[below left] at (0,0) {\footnotesize \bfseries 0};
}
\draw[cyan] (0,3) node[rotate=90,fill=white] () {\bfseries Text on y axis};
\draw(3,4) node[fill=red,draw=blue] () {\bfseries Text on the plane};
\draw[blue,line width=2pt] plot[domain=-5:5,smooth] (\x,{2*sin(\x r)});
\end{tikzpicture}
\begin{tikzpicture}[xshift=8,scale=.7]
% grid and axis
\draw[gray!15] (-6,-6) grid (6,6);
\draw[line width=.5pt,-latex] (-6,0)--(6,0) node[right] () {\small $x$};
\draw[line width=.5pt,-latex] (0,-6)--(0,6) node[above] () {\small $y$};
\foreach \i in {-6,-5,...,-1,1,2,...,5}{
\draw[thick] (\i,0)--(\i,-.05) node[below] () {\footnotesize \bfseries \i} ;
\draw[thick] (0,\i)--(-.05,\i) node[left] () {\footnotesize \bfseries \i} ;
\node[below left] at (0,0) {\footnotesize \bfseries 0};
}
\draw[cyan] (0,3) node[rotate=90,fill=white] () {\bfseries Text on y axis};
\draw(3,4) node[fill=red,draw=blue] () {\bfseries Text on the plane};
\draw[green,line width=2pt] plot[domain=-5:5,smooth] (\x,{2*cos(\x r)});
\end{tikzpicture}
\end{document}