1

I want to draw the figure where x size and y size will be different. Mark of x will be like 10, 20, 30 etc. and y will be 0.1, 0.2, 0.3 etc.

It will be also nice if there is a small grid in the back ground.

\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}

I can do the following. Now need to increase y axis scale.

\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}
  • A few notes ahead: You cannot use x and y as these will be overwritten by pgfplots anyway to setup the picture. The \centering inside the tikzpicture probably should go outside of it in the figure environment. You only have y values of 0.33. Is there a real use-case here? — You should check the options /pgfplots/xmin, xmax, ymin and ymax where you can set the values of the axes. – Qrrbrbirlbel Sep 1 '13 at 4:47
2

With coordinates given, you simply use

\draw plot [options]{some coordinates}; % don't forget this ; 

while \addplot needs pgfplots and \begin{axis} ... \end{axis} which is a bit more to setup. In short, \draw plot and \addplot are easily confused. I use the smaller datum to plot. However, You could easily copy and paste those desired datum and set grid to (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}

enter image description here

Updated:

\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}

enter image description here

  • yes, but I want to use \begin{axis}, as \addlegendentry is already there. – user12290 Sep 1 '13 at 14:30
  • @user12290 -- Please see my update. – Jesse Sep 1 '13 at 15:25
  • Thanks. Is it possible a rectangular figure with more y spacing? y coordinates are dense now. – user12290 Sep 1 '13 at 15:34
  • OK, set ymax=1.0. – Jesse Sep 1 '13 at 15:57
  • No actually I want more space 0.2, 0.3 etc in the y axis. – user12290 Sep 1 '13 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.