TransWikia.com

PGFPlots intersection segments wrong curve and endpoint

TeX - LaTeX Asked on May 19, 2021

When trying to answer How to delete a part of a curve in Tikz? , I ran into problems with intersection segments from PGFPlots fillbetween.
I tried to change the curve from to[out=280,in=175] to control points, and several other thing. I always get the same result:

  • red L1 seems right.
  • green L2 follow the curve, but has a wrong endpoint.
  • blue L3 has correct endpoints, but do not follow the curve.

What am I doing wrong?

documentclass[tikz, border=1cm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=newest}
usepgfplotslibrary{fillbetween}
begin{document}
begin{tikzpicture}
draw[name path=curve] (0.3,5) to[out=280,in=175, looseness=0.92] (5.5,0.5); %a curve
%draw[name path=curve] (0.3,5) .. controls (1,1) and (2,0) .. (5.5,0.5); %alternative curve
draw[name path=line] (0,4.1) -- (4.1,0);
draw[red, ultra thick, opacity=0.5, smooth, intersection segments={of=curve and line, sequence={L1}}];
pgfgetlastxy{XCoord}{YCoord}
draw (XCoord,YCoord) circle (1pt);
draw[green, ultra thick, opacity=0.5, smooth, intersection segments={of=curve and line, sequence={L2}}];
pgfgetlastxy{XCoord}{YCoord}
draw (XCoord,YCoord) circle (1pt);
draw[blue, ultra thick, opacity=0.5, smooth, intersection segments={of=curve and line, sequence={L3}}];
pgfgetlastxy{XCoord}{YCoord}
draw (XCoord,YCoord) circle (1pt);
end{tikzpicture}  
end{document} 

Curve and line with intersection segments

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP