1

I'd like to get the plot in the following figure (without grid):

enter image description here

Until now I got only axis+point:

\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}

\begin{tikzpicture}
\begin{axis}
\addplot[color=red,mark=square]coordinates{(2,2)};
\end{axis}
\end{tikzpicture}

Thank you very much for your time.

2

You mean something like the following?

% used PGFPlots v1.15
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        compat=1.11,
    }
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        xmin=0,     xmax=8,
        ymin=0,     ymax=8,
        xlabel={$x$},
        ylabel={$y$},
        axis lines=center,
        xtick={1,2},
        ytick={1,2},
    ]
        \addplot [color=red,mark=*] coordinates {(2,2)};

        \draw [dashed,help lines] (0,2) -| (2,0);
    \end{axis}
\end{tikzpicture}
\end{document}

image showing the result of above code

  • Hello @StefanPinnow, how come it does not work if I use compat=1.9? – Gennaro Arguzzi Nov 5 '17 at 13:36
  • @GennaroArguzzi, because then the TikZ coordinates have to be preceded by axis cs:, i.e. you have write \draw [dashed,help lines] (axis cs:0,2) -| (axis cs:2,0);. – Stefan Pinnow Nov 5 '17 at 15:08
  • @GennaroArguzzi, you are welcome. – Stefan Pinnow Nov 5 '17 at 19:55

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.