Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I generated some pgf/tikz code with Geogebra with good result

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black] (-6.72,0) -- (7.8,0);
\foreach \x in {-6,-4,-2,2,4,6}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
\draw[->,color=black] (0,-3.75) -- (0,7.03);
\foreach \y in {-2,2,4,6}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
\draw(3,-1) circle (2cm);
\fill [color=black] (-3,0) circle (1.5pt);
\draw [color=black] (-2.9,-0.26)-- ++(-1.5pt,-1.5pt) -- ++(3.0pt,3.0pt) ++(-3.0pt,0) -- ++(3.0pt,-3.0pt);
\end{tikzpicture}

On the other hand I draw a figure based on a coordinate file, works fine

\begin{tikzpicture}[]
\begin{axis}[axis x line=none, axis y line=none]
\addplot[smooth, color=black] file[]{coords.txt};
\end{axis}
\end{tikzpicture}

I can't seem to join this in one graph (same coordinate system). \addplot doesn't work without the axis environment and \draw produces a lot of errors and don't follow the same coordinates when put inside the axis environment.

I know there's some big gap in my understanding of pgf/tikz but how can the graphs be succesfully joined?

share|improve this question
    
I think you can include line \draw plot[smooth] file {coords.txt} in your geogebra tikzpicture code and will get what you want. –  Ignasi Aug 14 '13 at 9:30
add comment

1 Answer

up vote 7 down vote accepted

You can include the axis environment in the tikzpicture generated by Geogebra. To align the coordinate systems, set anchor=origin in the axis options, and choose the same x and y lengths:

\documentclass{article}
\usepackage{tikz, pgfplots}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black] (-6.72,0) -- (7.8,0);
\foreach \x in {-6,-4,-2,2,4,6}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
\draw[->,color=black] (0,-3.75) -- (0,7.03);
\foreach \y in {-2,2,4,6}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
\draw(3,-1) circle (2cm);
\fill [color=black] (-3,0) circle (1.5pt);
\draw [color=black] (-2.9,-0.26)-- ++(-1.5pt,-1.5pt) -- ++(3.0pt,3.0pt) ++(-3.0pt,0) -- ++(3.0pt,-3.0pt);

\begin{axis}[
    anchor=origin,  % Align the origins
    x=1cm, y=1cm,   % Set the same unit vectors
    hide axis
]
\addplot [mark=*, color=red] table {
4 5
-2 -2
-4 0
};
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
    
Thank you, the axis options you provided made everything work! –  Anders Aug 14 '13 at 10:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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