I would like to scale my TiKZ plots using different scale for X axis and Y axis. The problem I had is the plot markers size are affected by the scale and do not maintain the aspect ratio. How do I maintain aspect ratio of the plot markers? There is no problem with maintaining aspect ratio of nodes. Thank you in advance.
Here is my code:
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{plotmarks,positioning,shapes,arrows,backgrounds}
\begin{document}
\begin{tikzpicture}[xscale=0.080,yscale=0.160]
\draw[step=20cm,gray!20,very thin] (0,0) grid (100,80);
\tikzstyle{neuron}=[circle,fill=black,minimum size=5pt,inner sep=0pt]
\tikzstyle{data}=[diamond,fill=red,minimum size=8pt,inner sep=0pt]
\tikzstyle{edge}=[dashed,thick,color=black!50]
\node[neuron] (n0) at (20.77, 61.16) {}; \node[neuron] (n1) at (70.78, 31.07) {};
\node[data] (d0) at (42.77, 21.16) {}; \node[data] (d1) at (52.78, 11.07) {};
\draw[edge] (n0) -- (n1);
\draw plot[only marks,mark=x,mark size=60pt,mark options={color=red,scale=1.0}] coordinates{
(62.46,25.59) (39.97,33.29) (60.67,39.50)
};
\draw plot[only marks,mark=*,mark size=60pt,mark options={color=black}] coordinates{
(59.56,62.57) (71.05,65.27)
};
\draw[->] (0,0) -- coordinate (x axis mid) (100,0);
\draw[->] (0,0) -- coordinate (y axis mid) (0,80);
\foreach \x in {0,20,...,100}
\draw (\x cm,1pt) -- (\x cm,-3pt) node[anchor=north,font=\footnotesize] {$\x$};
\foreach \y in {0,20,...,80}
\draw (1pt,\y cm) -- (-3pt,\y cm) node[anchor=east,font=\footnotesize] {$\y$};
\end{tikzpicture}
\end{document}
Best Answer
You can change the
x
andy
units instead of usingxscale
andyscale
. This way only coordinates are scaled, not the markers:Note that I added
cm
to the "scaling" factors, but removed it for the grid and in the two trailing\foreach
loops.