1

Can I fill my square marks in yellow? When mark are *, I just can write fill=yellow

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{float}
\begin{document}
\begin{figure}[H]
    \centering
    \begin{tikzpicture}
        \begin{axis}[
                legend pos=outer north east,
                legend cell align={left},
                xmax=10,xmin=0,
                ymax=6,ymin=0,
                yticklabels=\empty, xticklabels=\empty,
                width=10cm,
                height=6cm,
                axis lines = middle,
                set layers,
                x label style={at={(1,0)},right},
                y label style={at={(0,1)},above},
                xlabel={$x$},ylabel={$y$},
                y tick style={draw=none}, x tick style={draw=none},
                style={thick}
            ]              
            \addplot [blue,smooth,very thick,domain=0:9] {-(5/9)*x +5};
            \addplot[only marks, mark=*,fill=yellow] coordinates { (0,5) (1,4.45) (3,3.34) (5,2.23) (7,1.12) (9,0) };
        \end{axis}
    \end{tikzpicture}
    \begin{tikzpicture}
        \begin{axis}[
                legend pos=outer north east,
                legend cell align={left},
                xmax=10,xmin=0,
                ymax=6,ymin=0,
                yticklabels=\empty, xticklabels=\empty,
                width=10cm,
                height=6cm,
                axis lines = middle,
                set layers,
                x label style={at={(1,0)},right},
                y label style={at={(0,1)},above},
                xlabel={$x$},ylabel={$y$},
                y tick style={draw=none}, x tick style={draw=none},
                style={thick}
            ]              
            \addplot [blue,smooth,very thick,domain=0:9] {-(5/9)*x +5};
            \addplot[only marks, mark=square,fill=yellow] coordinates { (0,5) (1,4.45) (3,3.34) (5,2.23) (7,1.12) (9,0) };
        \end{axis}
    \end{tikzpicture}
\end{figure}    
\end{document}

enter image description here

1

1 Answer 1

1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines = middle,
xmin=0, xmax=10,
ymin=0, ymax=6,
]              
\addplot[blue, very thick, samples at={0,1,3,5,7,9}, mark=square*, mark options={black, thin, fill=yellow}] {-(5/9)*x +5};
\end{axis}
\end{tikzpicture}
\end{document}

Linear graph with yellow marks

1

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.