1

I may be going about this the wrong way, but I'm trying to highlight a specific point on a graph using tikz and pgfplots. Currently I'm using a node to draw a circle round the point - however, I would ideally like to change thus to something more like an 'x'.

My code is as follows, and any help would be immensely appreciated.

\documentclass[1cm]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
    axis lines = left,
    xlabel = {Good 1},
    ylabel = {Good 2},
    xmin=0,
    xmax=450,
    ymin=0, 
    ymax=450,
    ytick={0,100,200,300,400,500},
    scaled y ticks = false,
    ]
    \addplot[] file[] {jointppf.dat};
    \node[draw,circle] ( ) at (250,300) {};
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

2
  • 1
    What about tickmarks? You may place it at any point. Check the manual for it. Oct 16, 2021 at 21:28
  • Please extend your code fragment to complete, compilable small document (MWE), that we can provide a complete solution. Meanwhile test if use of \node at (250,300) {$\times$}; and/or \addplot [mark=x] coordinates {(250,300)}; gives what you after.
    – Zarko
    Oct 17, 2021 at 7:55

1 Answer 1

1

You could either use : \addplot[mark=x,mark size=3] coordinates {(250,300)};

\documentclass[1cm]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        axis lines = left,
        xlabel = {Good 1},
        ylabel = {Good 2},
        xmin=0,
        xmax=450,
        ymin=0, 
        ymax=450,
        ytick={0,100,200,300,400,500},
        scaled y ticks = false,
        ]
        \addplot[] coordinates
        {(0,420) (250,300) (400,0)};
        \addplot[mark=x,mark size=3] coordinates
        {(250,300)};
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

or: \node at (axis cs:250,300) {\sffamily{x}};

\documentclass[1cm]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        axis lines = left,
        xlabel = {Good 1},
        ylabel = {Good 2},
        xmin=0,
        xmax=450,
        ymin=0, 
        ymax=450,
        ytick={0,100,200,300,400,500},
        scaled y ticks = false,
        ]
        \addplot[] coordinates
        {(0,420) (250,300) (400,0)};
        \node at (axis cs:250,300) {\sffamily{x}};
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .