0

MWE

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pgfplots}\pgfplotsset{compat=1.18}

\begin{document}
\begin{tikzpicture}
\begin{axis}
[
    % explicitly specify axis limits
    xmin=0,xmax=1,ymin=0,ymax=1,zmin=18,zmax=26,
    xlabel={x},
    ylabel={y},
    grid,
    % do not clip the \draw commands and clip each
    % addplot to its domain
    clip mode=individual,
]
% line on the xy plane (that way goes behind the surface)
% we mark a point at 30% of the line
\draw[thick]  (0.4,0,18) -- (0.4,1,18) coordinate[pos=0.3](a);
% line  touching the parabola
\draw[thick]  (0.4,0,18) -- (0.4,0.3,25-5*0.4*0.4-0.3*0.3) coordinate[pos=0.3](b);% coordinate on the black parabola
% main surface, semi-transparent
\addplot3[blue, no marks, surf, domain=0:1, samples=10, opacity=0.9] {25-5*x*x -y*y};
% graph restricted at at y=0.3 (parametric curve format)
\addplot3[ultra thick, no marks, domain=0:1, samples=10, samples y=1] (x, 0.3, 25-5*x*x -0.3*0.3);
% draw spline and angle label
% in and out are the angle at which the curve leaves the final and initial point
\draw[thick,->] (a) to[out=100, in=-10]  node[midway, above right]{$\alpha$} (b);

\end{axis}
\end{tikzpicture}
\end{document}

What does coordinate[pos=0.3] do in a \draw command? like does it have to do with somekind of panning in the graph?

Another question:

Tell me a wonderful way to put pgfplot examples in the public domain. I am thinking a GitHub repository such as APEXCalculus. Do any of you have a good idea?

1
6

As a personal advice, you should really go through the tutorials in the Tikz manual, especially the first one; otherwise you will spend much more time with this kind of doubts. pgfplots is based on TikZ, and as you need basic arithmetic to understand algebra, so you should learn TikZ to use pgfplots or other libraries based on it.

Anyway

\draw (0,0) -- (1,1); 

draws a line from (0,0) to (1,1) in the current coordinate system.

\draw (0,0) -- (1,1) coordinate(A);

gives a name to the coordinate (1,1) that you can reuse (so that for example, you can change coordinates in a drawing in just one place).

\draw (0,0) -- (1,1) coordinate[pos=0.3145](B);

gives a name to the coordinate in the segment from (0,0) to (1,1) at the position 0.3145 (where 0 corresponds to (0,0) and 1 to (1,1)).

Example:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[]
    \draw (0,0) -- (1,1) coordinate(A);
    \draw (0,-2) -- (1,-1) coordinate[pos=0.3](B);
    \draw [red] (A) -- (B);
\end{tikzpicture}
\end{document}

enter image description here

1
  • 1
    I think you might've been mad at me for not accepting your detailed answer or even comment. My appologies. What happened was this: My computer temporarly broke; went to the otther computer; then got a site/login error. (the error - meta.stackoverflow.com/questions/409433/…) Yikes! Now I am on my primary computor!!! YAY. So your answer is great, just pure platinum. I will reply after reading the answer Jul 31 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.