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'm using TeXgraph to create figures and stuff, being a bit lazy and not wanting to code everything. I chose to export the code into tikz to use with tikzpicture. The outcome is great if I don't have to scale anything, but when it comes to scaling, things aren't pretty.

I tried the built-in scale option of tikzpicture but this does not scale the text so it does not come out right. I then tried using the command \pgftransformscale, which got things a little better but it only gave me what I wanted, in terms of scaling when used in par with \pgflowlevel. However the placement is wrong and I have no idea how to move it. Here is a short example to see what I mean. First one is the original size, second one a smaller one with a half scale factor

Soit le graphique suivant: \\
% TeXgraph version 1.97
\begin{tikzpicture}%
%\pgflowlevel{\pgftransformscale{0.5}}
\useasboundingbox (-5.5,-5.5)--(5.5,5.5);
%objet6  (Utilisateur)
%objet1  (Grille)
\pgfsetstrokecolor{rgb,1:red,0.7529;green,0.7529;blue,0.7529}
\pgfsetlinewidth{0.4pt} 
\pgfsetroundjoin \pgfxyline(0,-5)(0,5)\pgfxyline(0.5,-5)(0.5,5)\pgfxyline(1,-5)    (1,5)\pgfxyline(1.5,-5)(1.5,5)
\pgfxyline(2,-5)(2,5)\pgfxyline(2.5,-5)(2.5,5)\pgfxyline(3,-5)(3,5)\pgfxyline(3.5,-5)(3.5,5)
\pgfxyline(4,-5)(4,5)\pgfxyline(4.5,-5)(4.5,5)\pgfxyline(5,-5)(5,5)\pgfxyline(-0.5,-5)(-0.5,5)
\pgfxyline(-1,-5)(-1,5)\pgfxyline(-1.5,-5)(-1.5,5)\pgfxyline(-2,-5)(-2,5)\pgfxyline(-2.5,-5)(-2.5,5)
\pgfxyline(-3,-5)(-3,5)\pgfxyline(-3.5,-5)(-3.5,5)\pgfxyline(-4,-5)(-4,5)\pgfxyline(-4.5,-5)(-4.5,5)
\pgfxyline(-5,-5)(-5,5)\pgfxyline(-5,0)(5,0)\pgfxyline(-5,0.5)(5,0.5)\pgfxyline(-5,1)(5,1)
\pgfxyline(-5,1.5)(5,1.5)\pgfxyline(-5,2)(5,2)\pgfxyline(-5,2.5)(5,2.5)\pgfxyline(-5,3)(5,3)
\pgfxyline(-5,3.5)(5,3.5)\pgfxyline(-5,4)(5,4)\pgfxyline(-5,4.5)(5,4.5)\pgfxyline(-5,5)(5,5)
\pgfxyline(-5,-0.5)(5,-0.5)\pgfxyline(-5,-1)(5,-1)\pgfxyline(-5,-1.5)(5,-1.5)\pgfxyline(-5,-2)(5,-2)
\pgfxyline(-5,-2.5)(5,-2.5)\pgfxyline(-5,-3)(5,-3)\pgfxyline(-5,-3.5)(5,-3.5)\pgfxyline(-5,-4)(5,-4)
\pgfxyline(-5,-4.5)(5,-4.5)\pgfxyline(-5,-5)(5,-5)
%objet2  (Axes)
\pgfsetstrokecolor{rgb,1:red,0;green,0;blue,0}
\pgfxyline(-5,0)(5,0)\pgfxyline(0,-5)(0,5)
\pgfsetfillcolor{rgb,1:red,0;green,0;blue,0}
\pgfxyline(0,-0.1)(0,0.1)\pgfxyline(1,-0.1)(1,0.1)\pgfxyline(2,-0.1)   (2,0.1)\pgfxyline(3,-0.1)(3,0.1)
\pgfxyline(4,-0.1)(4,0.1)\pgfxyline(5,-0.1)(5,0.1)
\pgfputat{\pgfxy(0.05,-0.2)}{\pgftext[top,left]{\small $0$}}
\pgfputat{\pgfxy(1,-0.2)}{\pgftext[top]{\small $1$}}
\pgfputat{\pgfxy(2,-0.2)}{\pgftext[top]{\small $2$}}
\pgfputat{\pgfxy(3,-0.2)}{\pgftext[top]{\small $3$}}
\pgfputat{\pgfxy(4,-0.2)}{\pgftext[top]{\small $4$}}
\pgfputat{\pgfxy(5,-0.2)}{\pgftext[top]{\small $5$}}
\pgfxyline(-1,-0.1)(-1,0.1)\pgfxyline(-2,-0.1)(-2,0.1)\pgfxyline(-3,-0.1)(-3,0.1)\pgfxyline(-4,-0.1)(-4,0.1)
\pgfxyline(-5,-0.1)(-5,0.1)
\pgfputat{\pgfxy(-1,-0.2)}{\pgftext[top]{\small $-1$}}
\pgfputat{\pgfxy(-2,-0.2)}{\pgftext[top]{\small $-2$}}
\pgfputat{\pgfxy(-3,-0.2)}{\pgftext[top]{\small $-3$}}
\pgfputat{\pgfxy(-4,-0.2)}{\pgftext[top]{\small $-4$}}
\pgfputat{\pgfxy(-5,-0.2)}{\pgftext[top]{\small $-5$}}
\pgfxyline(-0.1,0)(0.1,0)\pgfxyline(-0.1,1)(0.1,1)\pgfxyline(-0.1,2)(0.1,2)\pgfxyline(-0.1,3)(0.1,3)
\pgfxyline(-0.1,4)(0.1,4)\pgfxyline(-0.1,5)(0.1,5)
\pgfputat{\pgfxy(-0.2,0.05)}{\pgftext[right,bottom]{\small $0$}}
\pgfputat{\pgfxy(-0.2,1)}{\pgftext[right]{\small $1$}}
\pgfputat{\pgfxy(-0.2,2)}{\pgftext[right]{\small $2$}}
\pgfputat{\pgfxy(-0.2,3)}{\pgftext[right]{\small $3$}}
\pgfputat{\pgfxy(-0.2,4)}{\pgftext[right]{\small $4$}}
\pgfputat{\pgfxy(-0.2,5)}{\pgftext[right]{\small $5$}}
\pgfxyline(-0.1,-1)(0.1,-1)\pgfxyline(-0.1,-2)(0.1,-2)\pgfxyline(-0.1,-3)(0.1,-3)\pgfxyline(-0.1,-4)(0.1,-4)
\pgfxyline(-0.1,-5)(0.1,-5)
\pgfputat{\pgfxy(-0.2,-1)}{\pgftext[right]{\small $-1$}}
\pgfputat{\pgfxy(-0.2,-2)}{\pgftext[right]{\small $-2$}}
\pgfputat{\pgfxy(-0.2,-3)}{\pgftext[right]{\small $-3$}}
\pgfputat{\pgfxy(-0.2,-4)}{\pgftext[right]{\small $-4$}}
\pgfputat{\pgfxy(-0.2,-5)}{\pgftext[right]{\small $-5$}}
%D4  (Droite)
\pgfxyline(1,-5)(-5,1)
%D5  (Droite)
\pgfxyline(3,5)(-5,-3)
%objet5  (Droite)
\pgfxyline(-4,-5)(2.6667,5)
%bs  (Point(s))
\pgfsetstrokecolor{rgb,1:red,0;green,0;blue,1}
\pgfsetfillcolor{rgb,1:red,0;green,0;blue,1}\pgfellipse[fillstroke]{\pgfxy(0,2)}  {\pgfxy(0,0.0492)}{\pgfxy(-0.0492,0)}
\pgfellipse[fillstroke]{\pgfxy(0,1)}{\pgfxy(0,0.0492)}{\pgfxy(-0.0492,0)}
\pgfellipse[fillstroke]{\pgfxy(0,-4)}{\pgfxy(0,0.0492)}{\pgfxy(-0.0492,0)}
\pgfputat{\pgfxy(-4,1)}{\pgftext{\color{rgb,1:red,0;green,0;blue,0}\small   $D4$}}\pgfstroke
\pgfputat{\pgfxy(-1,1.5)}{\pgftext{\color{rgb,1:red,0;green,0;blue,0}\small $D5$}}\pgfstroke
\pgfputat{\pgfxy(0.5,1)}{\pgftext{\color{rgb,1:red,0;green,0;blue,0}\small   $D6$}}\pgfstroke
\end{tikzpicture}%

And for the scaled one

Soit le graphique suivant: \\
% TeXgraph version 1.97
\begin{tikzpicture}%
\pgflowlevel{\pgftransformscale{0.5}}
\useasboundingbox (-5.5,-5.5)--(5.5,5.5);
%objet6  (Utilisateur)
%objet1  (Grille)
\pgfsetstrokecolor{rgb,1:red,0.7529;green,0.7529;blue,0.7529}
\pgfsetlinewidth{0.4pt} 
\pgfsetroundjoin \pgfxyline(0,-5)(0,5)\pgfxyline(0.5,-5)(0.5,5)\pgfxyline(1,-5)    (1,5)\pgfxyline(1.5,-5)(1.5,5)
\pgfxyline(2,-5)(2,5)\pgfxyline(2.5,-5)(2.5,5)\pgfxyline(3,-5)(3,5)\pgfxyline(3.5,-5)(3.5,5)
\pgfxyline(4,-5)(4,5)\pgfxyline(4.5,-5)(4.5,5)\pgfxyline(5,-5)(5,5)\pgfxyline(-0.5,-5)(-0.5,5)
\pgfxyline(-1,-5)(-1,5)\pgfxyline(-1.5,-5)(-1.5,5)\pgfxyline(-2,-5)(-2,5)\pgfxyline(-2.5,-5)(-2.5,5)
\pgfxyline(-3,-5)(-3,5)\pgfxyline(-3.5,-5)(-3.5,5)\pgfxyline(-4,-5)(-4,5)\pgfxyline(-4.5,-5)(-4.5,5)
\pgfxyline(-5,-5)(-5,5)\pgfxyline(-5,0)(5,0)\pgfxyline(-5,0.5)(5,0.5)\pgfxyline(-5,1)(5,1)
\pgfxyline(-5,1.5)(5,1.5)\pgfxyline(-5,2)(5,2)\pgfxyline(-5,2.5)(5,2.5)\pgfxyline(-5,3)(5,3)
\pgfxyline(-5,3.5)(5,3.5)\pgfxyline(-5,4)(5,4)\pgfxyline(-5,4.5)(5,4.5)\pgfxyline(-5,5)(5,5)
\pgfxyline(-5,-0.5)(5,-0.5)\pgfxyline(-5,-1)(5,-1)\pgfxyline(-5,-1.5)(5,-1.5)\pgfxyline(-5,-2)(5,-2)
\pgfxyline(-5,-2.5)(5,-2.5)\pgfxyline(-5,-3)(5,-3)\pgfxyline(-5,-3.5)(5,-3.5)\pgfxyline(-5,-4)(5,-4)
\pgfxyline(-5,-4.5)(5,-4.5)\pgfxyline(-5,-5)(5,-5)
%objet2  (Axes)
\pgfsetstrokecolor{rgb,1:red,0;green,0;blue,0}
\pgfxyline(-5,0)(5,0)\pgfxyline(0,-5)(0,5)
\pgfsetfillcolor{rgb,1:red,0;green,0;blue,0}
\pgfxyline(0,-0.1)(0,0.1)\pgfxyline(1,-0.1)(1,0.1)\pgfxyline(2,-0.1)   (2,0.1)\pgfxyline(3,-0.1)(3,0.1)
\pgfxyline(4,-0.1)(4,0.1)\pgfxyline(5,-0.1)(5,0.1)
\pgfputat{\pgfxy(0.05,-0.2)}{\pgftext[top,left]{\small $0$}}
\pgfputat{\pgfxy(1,-0.2)}{\pgftext[top]{\small $1$}}
\pgfputat{\pgfxy(2,-0.2)}{\pgftext[top]{\small $2$}}
\pgfputat{\pgfxy(3,-0.2)}{\pgftext[top]{\small $3$}}
\pgfputat{\pgfxy(4,-0.2)}{\pgftext[top]{\small $4$}}
\pgfputat{\pgfxy(5,-0.2)}{\pgftext[top]{\small $5$}}
\pgfxyline(-1,-0.1)(-1,0.1)\pgfxyline(-2,-0.1)(-2,0.1)\pgfxyline(-3,-0.1)(-3,0.1)\pgfxyline(-4,-0.1)(-4,0.1)
\pgfxyline(-5,-0.1)(-5,0.1)
\pgfputat{\pgfxy(-1,-0.2)}{\pgftext[top]{\small $-1$}}
\pgfputat{\pgfxy(-2,-0.2)}{\pgftext[top]{\small $-2$}}
\pgfputat{\pgfxy(-3,-0.2)}{\pgftext[top]{\small $-3$}}
\pgfputat{\pgfxy(-4,-0.2)}{\pgftext[top]{\small $-4$}}
\pgfputat{\pgfxy(-5,-0.2)}{\pgftext[top]{\small $-5$}}
\pgfxyline(-0.1,0)(0.1,0)\pgfxyline(-0.1,1)(0.1,1)\pgfxyline(-0.1,2)(0.1,2)\pgfxyline(-0.1,3)(0.1,3)
\pgfxyline(-0.1,4)(0.1,4)\pgfxyline(-0.1,5)(0.1,5)
\pgfputat{\pgfxy(-0.2,0.05)}{\pgftext[right,bottom]{\small $0$}}
\pgfputat{\pgfxy(-0.2,1)}{\pgftext[right]{\small $1$}}
\pgfputat{\pgfxy(-0.2,2)}{\pgftext[right]{\small $2$}}
\pgfputat{\pgfxy(-0.2,3)}{\pgftext[right]{\small $3$}}
\pgfputat{\pgfxy(-0.2,4)}{\pgftext[right]{\small $4$}}
\pgfputat{\pgfxy(-0.2,5)}{\pgftext[right]{\small $5$}}
\pgfxyline(-0.1,-1)(0.1,-1)\pgfxyline(-0.1,-2)(0.1,-2)\pgfxyline(-0.1,-3)(0.1,-3)\pgfxyline(-0.1,-4)(0.1,-4)
\pgfxyline(-0.1,-5)(0.1,-5)
\pgfputat{\pgfxy(-0.2,-1)}{\pgftext[right]{\small $-1$}}
\pgfputat{\pgfxy(-0.2,-2)}{\pgftext[right]{\small $-2$}}
\pgfputat{\pgfxy(-0.2,-3)}{\pgftext[right]{\small $-3$}}
\pgfputat{\pgfxy(-0.2,-4)}{\pgftext[right]{\small $-4$}}
\pgfputat{\pgfxy(-0.2,-5)}{\pgftext[right]{\small $-5$}}
%D4  (Droite)
\pgfxyline(1,-5)(-5,1)
%D5  (Droite)
\pgfxyline(3,5)(-5,-3)
%objet5  (Droite)
\pgfxyline(-4,-5)(2.6667,5)
%bs  (Point(s))
\pgfsetstrokecolor{rgb,1:red,0;green,0;blue,1}
\pgfsetfillcolor{rgb,1:red,0;green,0;blue,1}\pgfellipse[fillstroke]{\pgfxy(0,2)}  {\pgfxy(0,0.0492)}{\pgfxy(-0.0492,0)}
\pgfellipse[fillstroke]{\pgfxy(0,1)}{\pgfxy(0,0.0492)}{\pgfxy(-0.0492,0)}
\pgfellipse[fillstroke]{\pgfxy(0,-4)}{\pgfxy(0,0.0492)}{\pgfxy(-0.0492,0)}
\pgfputat{\pgfxy(-4,1)}{\pgftext{\color{rgb,1:red,0;green,0;blue,0}\small   $D4$}}\pgfstroke
\pgfputat{\pgfxy(-1,1.5)}{\pgftext{\color{rgb,1:red,0;green,0;blue,0}\small $D5$}}\pgfstroke
\pgfputat{\pgfxy(0.5,1)}{\pgftext{\color{rgb,1:red,0;green,0;blue,0}\small   $D6$}}\pgfstroke
\end{tikzpicture}%

I'd like to know if there would be a way to move the rendered object, or another way of scaling that would do it by itself.

share|improve this question
    
I don't see any unscaled text. Which text exactly is that you see unscaled? –  percusse Sep 12 '12 at 16:10
    
With the combination of pgflowlevel and transform scale, the text is scaled all right but the placement of the figure is wrong, I'd like to be able to move it. –  Jean-Sébastien Sep 12 '12 at 17:12
add comment

1 Answer 1

You can get away with a proper picture by using the scale a little differently. So change the scaled picture's initial line with the following.

\begin{tikzpicture}[baseline=(current bounding box.center),transform canvas={scale around={0.5:(5,-5)}}]% <- Changed

But I think laziness is not a valid excuse as you have experienced that there is no control over the resulting picture hence it takes more effort. In fact, it's quite simple to do it via pgfplots

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\noindent Soit le graphique suivant:

\begin{tikzpicture}[mydot/.style={blue,inner sep=1pt,fill,circle}]
\begin{axis}[no marks,
xmin=-5,xmax=5,
ymin=-5,ymax=5,
grid=both,
axis lines=middle,
axis line style={-|},
xtick={-5,...,5},
ytick={-5,...,5},
minor tick num=1,
x=1cm,y=1cm
]
\addplot {x+2};
\addplot {1.5*x+1};
\addplot {-x-4};
\node[mydot] at (axis cs:0,1) {};
\node[mydot] at (axis cs:0,2) {};
\node[mydot] at (axis cs:0,-4) {};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
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.