Graphics, Figures & TablestikZ | Plotting Problem

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
johnnydarten
Posts: 4
Joined: Mon May 02, 2011 10:18 pm

tikZ | Plotting Problem

Post by johnnydarten »

Hi all, I have a problem with Texmaker. I tried to plot numbers in a file (CaseA.dat) using the code below and it worked fine except that y-axis data points were plotted very close from each other.

Code: Select all

\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage[left=4.5cm,right=4.5cm,top=4cm,bottom=4cm]{geometry}
\begin{document}
\pagestyle{empty}

\begin{center}
\makebox[0pt][c]{\begin{tikzpicture}[x=0.28cm,y=3cm]

\def\xmin{0}
\def\xmax{31}
\def\ymin{0.5}
\def\ymax{3.6}


\draw[thick,->] (0,0.5) -- (33,0.5) node [right] {$Freq(GHz)$};
\draw[thick,->] (0,0.5) -- (0,3.8)node [right] {$S11$};

\foreach \s/\x in {0/30, 5/35, 10/40, 15/45, 20/50, 25/55, 30/60}
{
\draw[thick,shift={(\x,0)}] (-239pt,39pt) -- (-239pt,45pt) node [below=10pt] {$\x$};
}
\foreach \n/\y in {0.5/0.62, 1/0.63, 1.5/0.64, 2/0.65, 2.5/0.66, 3/0.67, 3.5/0.68}
{
\draw[thick,shift={(0,\n)}] (3pt,0pt) --(-3pt,0pt) node [left=5pt]{$\y$};
}


\draw[thick,color=blue] plot[smooth] file {CaseA.dat}; 

\draw[style=help lines, ystep=0.5, xstep=5] (\xmin,\ymin) grid
(\xmax,\ymax);

\end{tikzpicture}
}
\end{center}

\end{document}
After that I added "yscale=50" to the line at which I import data from my file so that it becomes:

Code: Select all

\draw[thick,color=blue, yscale=50] plot[smooth] file {CaseA.dat};
In this case the code compiles but everything disappears except my desired plot (grid,axes,... all disappear)..I just want this scaled drawing to appear on my grid...Can somebody help? My data file is attached

Thanks and waiting for reply
Attachments
CaseA.dat
(394 Bytes) Downloaded 123 times
Last edited by johnnydarten on Fri Jul 29, 2011 10:01 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

tikZ | Plotting Problem

Post by localghost »

Your problem is not related to TeXmaker at all. And there is a much smarter way by the pgfplots package to generate plots.

Code: Select all

\documentclass{minimal}
\usepackage{pgfplots}

\begin{document}
  \begin{tikzpicture}
    \begin{axis}[%
      grid=major,
      xmin=0,xmax=30,ymin=0.62,ymax=0.68,
      xlabel={Frequency / GHz},
      ylabel={S11},
      xlabel near ticks,
      ylabel near ticks
    ]
      \addplot[smooth,blue] table {CaseA.dat};
    \end{axis}
  \end{tikzpicture}
\end{document}
For further customization refer to the package manual.


Thorsten
johnnydarten
Posts: 4
Joined: Mon May 02, 2011 10:18 pm

Re: tikZ | Plotting Problem

Post by johnnydarten »

Thanks
Post Reply