0

In a separate post, @00dani provided a nifty way of labeling points with TikZ's pin option which I'm trying to mimic.

options for labeling single point

Specifically, in a system of 1 quadratic and 1 liner equation, I want to label the 2 intersection points. The solution set for the system = (-6,3) and (-3,-3).

Presently the pointers aren't referring to the correct intersection points.

enter image description here

The desired graph is:

enter image description here

Maybe the graph is too crowded to allow for labeling the intersection points. @kissmyarmpit suggests PSTricks package to place a simple large black dot.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\usepackage{pst-eucl}
\def\f(#1){x^2+0.5}

Personally, I know very little about TiKz graphing and appreciate your most readable solution for labeling the points.

Thank you!

mwe

\usepackage{pgfplots}
\begin{document}
\begin{center}
  \begin{tikzpicture}
  \begin{axis}[
      % width and height if axis, adjust to your liking
      width=7cm,
      height=6cm,
%xtick=\empty, 
% remove all ticks from x-axis
%ytick=\empty, % ditto for y-axis
      xlabel=$x$, 
      ylabel=$y$,
      axis lines=center, % default is to make a box around the axis
      domain=-10.5:5,
      samples=100]
    \addplot [red] {-2*x-9};
   \addplot [blue] {2(x+4)^2-5};
%callout for intersection point
\addplot[mark=*] coordinates {(-6,3)} node[pin=150:{$(-6,3)$}]{} ;
\addplot[mark=*] coordinates {(-3,-3)} node[pin=150:{$(-3,-3)$}]{} ;
  \end{axis}
  \end{tikzpicture}
\end{center}
\end{document}
Siuslaw Math
  • 641
  • 3
  • 8
  • On your picture, the coordinates don't seem to sit at the intersections. Are you sure that (-6,3) and (-3,-3) are the correct coordinates for the intersections? – Jasper Habicht Apr 17 '23 at 22:16
  • @JasperHabicht Yes, those solutions are correct for the system of equations. (checked in symbolab.com) The scales for the x & y axes are needlessly different, thus distorting the point plots. Need to fix that problem, but not sure how. Thank you! – Siuslaw Math Apr 17 '23 at 22:44
  • But even if the axis are scaled differently, the coordinates should still be right. You are missing a * in the formula. See my answer. – Jasper Habicht Apr 18 '23 at 07:26

1 Answers1

1

I think, you are missing a * in the formula for the parabola. With 2*(x+4)^2-5, you get the right plot. You can play with xmin, xmax, ymin and ymax to restrict the domains and scale the diagram. Also, maybe decrease the font size or reduce the number of ticks. I would probably not use pins to add the labels.

Apart from that, you can find the intersection coordinates using the intersections library provided by TikZ:

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{intersections}

\begin{document} \begin{tikzpicture} \begin{axis}[ width=7cm, height=6cm, xmin=-10, xmax=5, ymin=-10, ymax=20, domain=-10.5:2.5, samples=100, xlabel=$x$, ylabel=$y$, axis lines=center, font=\scriptsize ] \addplot[red, name path global=line] {-2x-9}; \addplot[blue, name path global=curve] {2(x+4)^2-5};

% intersection point
\path[name intersections={of=line and curve, name=i}];
\fill (i-1) circle[radius=2pt] node[left] {$(-6,3)$};
\fill (i-2) circle[radius=2pt] node[right] {$(-3,-3)$};

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

enter image description here

  • Thanks very much for the simple, but quite elegant solution. Going forward, I will pay careful attention to including the asterisk! – Siuslaw Math Apr 18 '23 at 15:13