我想绘制 x 尺寸和 y 尺寸不同的图形。x 的标记将是 10、20、30 等,y 将是 0.1、0.2、0.3 等。
如果背景有一个小网格就更好了。
\begin{figure}[]
\begin{tikzpicture}[x=0.080cm,y=40.160cm] \centering
\begin{axis}[
ylabel=$\delta \uparrow $,
xlabel=$p \rightarrow$,
legend style={
at={(0.95,0.05)},
anchor=south east
},
axis equal image]
\addplot[no marks] coordinates{ ( 2 , 0.33 ) ( 3 , 0.33 ) ( 4 , 0.33 ) ( 5 , 0.33 ) ( 6 , 0.33 ) ( 7 ,
0.33 ) ( 8 , 0.33 ) ( 9 , 0.33 ) ( 10 , 0.33 ) ( 11 , 0.33 ) ( 12 , 0.33 ) ( 13 , 0.33 ) ( 14 , 0.33 ) ( 2 , 0.33 ) ( 3 , 0.33 ) ( 4 , 0.33 ) ( 5 , 0.33 ) ( 6 , 0.33 ) ( 7 ,
0.33 ) ( 8 , 0.33 ) ( 9 , 0.33 ) ( 10 , 0.33 ) ( 11 , 0.33 ) ( 12 , 0.33 ) ( 13 , 0.33 ) ( 14 , 0.33 ) ( 15 , 0.33 ) ( 16 , 0.33 ) ( 17 , 0.33 ) ( 18 , 0.33 ) ( 19 , 0.33 ) ( 20 , 0.33 ) ( 21 , 0.33 ) ( 22 , 0.33 ) ( 23 , 0.33 ) ( 24 , 0.33 ) ( 25 , 0.33 ) ( 26 , 0.33 ) ( 27 , 0.33 ) ( 28 , 0.33 ) ( 29 , 0.33 ) ( 30 , 0.33 ) ( 31 , 0.33 ) ( 32 , 0.33 ) ( 33 ,
0.33 ) ( 34 , 0.33 ) ( 35 , 0.33 ) ( 36 , 0.33 ) ( 37 , 0.33 ) ( 38 ,
0.33 ) ( 39 , 0.33 ) ( 40 , 0.33 ) ( 41 , 0.33 ) ( 42 , 0.33 ) ( 43 ,
0.33 ) ( 44 , 0.33 ) ( 45 , 0.33 ) ( 46 , 0.33 ) ( 47 , 0.33 ) ( 48 ,
0.33 ) ( 49 , 0.33 ) ( 50 , 0.33 ) ( 51 , 0.33 ) ( 52 , 0.33 ) ( 53 ,
0.33 ) ( 54 , 0.33 ) ( 55 , 0.33 ) ( 56 , 0.33 ) ( 57 , 0.33 ) ( 58 ,
0.33 ) ( 59 , 0.33 ) ( 60 , 0.33 ) ( 61 , 0.33 ) ( 62 , 0.33 ) ( 63 ,
0.33 ) ( 64 , 0.33 ) ( 65 , 0.33 ) ( 66 , 0.33 ) ( 67 , 0.33 ) ( 68 ,
0.33 ) ( 69 , 0.33 ) ( 70 , 0.33 ) ( 71 , 0.33 ) ( 72 , 0.33 ) ( 73 ,
0.33 ) ( 74 , 0.33 ) ( 75 , 0.33 ) ( 76 , 0.33 ) ( 77 , 0.33 ) ( 78 ,
0.33 ) ( 79 , 0.33 ) ( 80 , 0.33 ) ( 81 , 0.33 ) ( 82 , 0.33 ) ( 83 ,
0.33 ) ( 84 , 0.33 ) ( 85 , 0.33 ) ( 86 , 0.33 ) ( 87 , 0.33 ) ( 88 ,
0.33 ) ( 89 , 0.33 ) ( 90 , 0.33 ) ( 91 , 0.33 ) ( 92 , 0.33 ) ( 93 ,
0.33 ) ( 94 , 0.33 ) ( 95 , 0.33 ) ( 96 , 0.33 ) ( 97 , 0.33 ) ( 98 ,
0.33 ) ( 99 , 0.33 ) };
\addlegendentry{$\tau(r)$}
\end{axis}
\end{tikzpicture}
\caption{}\label{fig1}
\end{figure}
我可以执行以下操作。现在需要增加 y 轴刻度。
\centering
\begin{figure}[]
\begin{tikzpicture}[]
\begin{axis}[scale only axis,
x=1.0cm,y=300cm, % units
ylabel=$\delta \uparrow $,xlabel=$p \rightarrow$,legend style={at={(0.95,0.05)},anchor=south east}, axis equal image,
xmin=2, xmax=15, ymin=0, ymax=1.0,
xtick = {0, 3, 6, 9, 12, 15}, ytick = {0.2, 0.3,0.4,0.5,0.6,0.7}]
\addplot[no marks] coordinates{ ( 2 , 0.33 ) ( 3 , 0.33 ) ( 4 , 0.33 ) ( 5 , 0.33 ) ( 6 , 0.33 ) ( 7 ,
0.33 ) ( 8 , 0.33 ) ( 9 , 0.33 ) ( 10 , 0.33 ) ( 11 , 0.33 ) ( 12 , 0.33
) ( 13 , 0.33 ) ( 14 , 0.33 ) ( 2 , 0.33 ) ( 3 , 0.33 ) ( 4 , 0.33 ) ( 5 , 0.33 ) ( 6 , 0.33 ) ( 7 ,
0.33 ) ( 8 , 0.33 ) ( 9 , 0.33 ) ( 10 , 0.33 ) ( 11 , 0.33 ) ( 12 , 0.33
) ( 13 , 0.33 ) ( 14 , 0.33 ) ( 15 , 0.33 ) };
\addlegendentry{$\tau(r)$}
\end{axis}
答案1
给定坐标后,你只需使用
\draw plot [options]{some coordinates}; % don't forget this ;
而\addplot
需要pgfplots
和 ,\begin{axis} ... \end{axis}
这需要更多的设置。简而言之,\draw plot
和\addplot
很容易混淆。我使用较小的数据来绘图。但是,您可以轻松复制和粘贴所需的数据并设置grid
为(0,0) grid (100,1)
。
\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1] % 0.5 for 50% reduction
\draw (0,0) grid (20,1);
\draw [->](0,0)--(0,1)node[above] {$y$}; % for y axis
\draw plot [mark=*,mark options={color=red},mark size=2pt]coordinates {( 2 , 0.33 )
( 3 , 0.33 ) (4, 0.33 ) (5, 0.33 ) (6,0.33 ) (7,0.33 ) (8,0.33 ) (9,0.33 )
(10,0.33 )(11, 0.33 ) (12, 0.33) (13, 0.33 ) (14, 0.33 ) (2, 0.33 ) (3, 0.33 )
(4,0.33 ) (5,0.33 ) (6,0.33 ) (7,0.33 ) (8,0.33 ) (9,0.33 )
(10, 0.33 ) (11, 0.33 ) (12, 0.33) (13, 0.33 ) (14, 0.33 ) (15, 0.33 )};
\end{tikzpicture}
\end{document}
更新:
\usepackage{tikz}
\usepackage{pgfplots}
\begin{tikzpicture}[scale=1]
\tikzset{small dot/.style={fill=black,circle, scale=1}}
\begin{axis}[
%x=1.0 cm,y=300cm, % units
ylabel=$\delta \uparrow $,
xlabel=$p \rightarrow$,
legend style={at={(0,1)}, anchor=north west},
%axis equal image,
xmin=2, xmax=15, ymin=0, ymax=2.0,
xtick = {0, 3, 6, 9, 12, 15}, ytick = {0.2, 0.3,0.4,0.5,0.6,0.7}]
]
\addplot+[smooth] coordinates {( 2 , 0.33 ) ( 3 , 0.33 ) (4, 0.33 ) (5, 0.33 )
(6,0.33 ) (7,0.33 ) (8,0.33 ) (9,0.33 ) (10,0.33 )
(11, 0.33 ) (12, 0.33) (13, 0.33 ) (14, 0.33 ) (2, 0.33 ) (3, 0.33 ) (4,0.33 )
(5,0.33 ) (6,0.33 ) (7,0.33 ) (8,0.33 ) (9,0.33 )
(10, 0.33 ) (11, 0.33 ) (12, 0.33) (13, 0.33 ) (14, 0.33 ) (15, 0.33 )};
\addlegendentry{Your label here}
\end{axis}
\end{tikzpicture}