pgf-tikz / pgfplots

pgfplots - A TeX package to draw normal and/or logarithmic plots directly in TeX in two and three dimensions with a user-friendly interface and pgfplotstable - a TeX package to round and format numerical tables. Examples in manuals and/or on web site.
http://pgfplots.sourceforge.net/
200 stars 35 forks source link

unit vector ratio does not behave as expected #80

Open pgf-tikz-bot opened 9 years ago

pgf-tikz-bot commented 9 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/80/ Author: ljeub Timestamp: 2015-03-20 16:02:12.891000

https://sourceforge.net/p/pgfplots/bugs/80/attachment/test.png Hi,

I was trying to implement 3d-plots with fixed aspect ratio (see https://github.com/matlab2tikz/matlab2tikz/pull/560), and I ran into issues with the behaviour of scale mode=scale uniformly and unit vector ratio.

Consider this example, which is set up such that the width and height constraints can both be satisfied simultaneously, and the unit vector ratio=2 2 1 is set up such that it should produce equivalent results to plot box ratio=3 2 1 which behaves as expected:

:::latex
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}

\begin{axis}[%
width=6.027778in,
height=4.310278in,
scale only axis,
plot box ratio=3 2 1,
% This plot is set up to have this unit vector ratio:
%unit vector ratio=2 2 1,
%unit vector ratio=4 4 2,
%
% width and height are setup to have the correct ratio, so the startegies should be equivalent:
%scale uniformly strategy=units only,
%scale uniformly strategy=change vertical limits,
%scale uniformly strategy=change horizontal limits,
xmin=-1,
xmax=2,
ymin=-1,
ymax=1,
zmin=-1,
zmax=1,
view={-37.5}{30},
]
\end{axis}

\begin{axis}[%
width=6.027778in,
height=4.310278in,
%
% these unit vector ratios should all be equivalent:
%unit vector ratio=1.4 1,
%unit vector ratio=0.7 0.5,
%unit vector ratio=2.8 2,
%unit vector ratio=1.54 1.1,
%
% width and height are setup to have the correct ratio, so the startegies should be equivalent:
%scale uniformly strategy=units only,
%scale uniformly strategy=change vertical limits,
%scale uniformly strategy=change horizontal limits,
scale only axis,
xmin=0,
xmax=1,
ymin=0,
ymax=1,
]
\end{axis}
\end{tikzpicture}%
\end{document}

Here is what the example looks like:

pgf-tikz-bot commented 9 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/80/#1bc7 Author: ljeub Timestamp: 2015-03-20 16:08:16.469000

https://sourceforge.net/p/pgfplots/bugs/_discuss/thread/f046cb65/1bc7/attachment/test2.png And here is what it looks like with unit vector ratio=2 2 1 for the 3d axis. Note that the aspect ratio of the 3d axis is correct but it does not expand to the specified width and height. Try uncommenting different combinations of unit vector ratio and scale uniformly strategy to see some other strange behaviour, such as differently sized axes for values of the unit vector ratio that should be equivalent.