Graphics, Figures & TablesTikZ Scaling Inconsistency

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

TikZ Scaling Inconsistency

Post by LaTexLearner »

I am trying to teach myself TikZ scaling for number lines. Apparently, there's something about scaling the x- and y-axes that I don't understand.

Why are the vertical tick marks different sizes for these two number lines if the y-scale is 1.8 for the first number line but the x- and y-scales are both 1.8 for the second?

Code: Select all

\documentclass[12pt]{article}

\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}[xscale=3][yscale=1.8] 
\draw[-latex] (0,0)--(2,0);
\foreach \x in {0,...,6}
\draw (\x/3,-0.1)--(\x/3,0.1);
\foreach \x in {0,...,2}
\node[below] at (\x,-0.15) {\x};    
\end{tikzpicture}

\vspace{3cm}

\begin{tikzpicture}[scale=1.8]
\draw[-latex] (0,0)--(4.5,0) ;
\foreach \x in {0,...,12}
\draw (\x/3,-0.1)--(\x/3,0.1);
\foreach \x in {0,...,4}				
\node[below] at (\x,-0.15) {\x};    
\end{tikzpicture} 

\end{document}

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

TikZ Scaling Inconsistency

Post by Stefan Kottwitz »

This is the problem:

Code: Select all

\begin{tikzpicture}[xscale=3][yscale=1.8]
As result, you gave just xscale as option. The [yscale=1.8] would be a second set of options, so in a second argument, but tikzpicture takes only one argument in square brackets, which has a list of key=value settings.

So, the correct way is:

Code: Select all

\begin{tikzpicture}[xscale=3,yscale=1.8]
Stefan
LaTeX.org admin
LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

Re: TikZ Scaling Inconsistency

Post by LaTexLearner »

Got it, thanks!
Post Reply