I'm dealing with a 3d plot. Let's consider the following MWE:
\documentclass{article}
\usepackage{pgf,pgfplots,pgfplotstable}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{colormaps}
\usepgfplotslibrary{groupplots}
\usetikzlibrary{arrows.meta}
\begin{filecontents*}{data.dat}
rx ry rz
-24.86780 0.00000 1.000
-24.41886 0.00002 1.000
-23.97329 0.00010 0.999
-23.53110 0.00022 0.998
-23.09230 0.00039 0.996
-22.65693 0.00061 0.994
-22.22498 0.00087 0.991
-21.79648 0.00118 0.988
-21.37144 0.00153 0.985
-20.94988 0.00192 0.981
-20.53182 0.00236 0.976
-20.11727 0.00285 0.972
\end{filecontents*}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}[
title = Trajectory,
xmin = -25, xmax = -19,
ymin = -1, ymax = 1,
zmin=0.8, zmax=1,
xtick distance = 5,
ytick distance = 1,
xlabel={$downrange$},
ylabel={$crossrange$},
zlabel={$altitude$},
y label style={sloped},
x label style={sloped},
grid = both,
grid style = {dotted},
minor tick num = 1,
major grid style = {lightgray!75},
minor grid style = {lightgray!75},
width = 0.85\textwidth,
height = 0.50\textwidth,
view={65}{40},
%scale only axis,
legend cell align = {left},
legend pos = north east
]
\addplot3 [smooth, black, ultra thick] table [x = {rx}, y = {ry}, z = {rz}] {data.dat};
\addplot3 [smooth, black, loosely dashed, ultra thick] table [x = {rx}, y = -{ry}, z = {rz}] {data.dat};
\legend{
n1 (k),
n1 (j),
}
\end{axis}
\end{tikzpicture}
\caption{plot}
\end{figure}
\end{document}
I would like to know how I could add a new plot, in addition to the one I've written, where the sign of every y is inverted. I've tried both y={-ry}
and y=-{ry}
inside a new addplot
, but it doesn't work. I suppose that in the first case the algorithm doesn't find any column named "-ry", that's why it reports the error, while I have no idea for the latter case.
Is there any strategy to change the sign of the values of a single column without creating a completely new data table?