0

I am working with tikzpicture to plot a few data points. I am trying to set the fill-color of my data points to something else than the default blue, but I don't see what I am doing wrong. I am sure I altered in the past the color by just changing the fill value, but it doesn't work in this case

I attached a MWE - can someone help me with this:

\documentclass[a4paper]{article} 
\usepackage{amsmath} 
\usepackage{times}
\usepackage{url}
\usepackage{latexsym}
\usepackage{booktabs}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx, subcaption}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{pgfplots, pgfplotstable}    
\usepackage{caption}
\usepackage{rotating}
\usepackage{nicefrac}
\usepackage{subfig}
\usetikzlibrary{spy}
\usepackage{color,colortbl}
\begin{document} 
\begin{figure*}
    \centering
    \begin{tikzpicture}
    \begin{semilogyaxis}[
        nodes near coords,
        ylabel={time [s]},      
        enlargelimits=0.2,
        log basis y=10,
    ]
        \addplot+[
            black,
            fill=red,
            only marks,
            point meta=explicit symbolic,
            visualization depends on=\thisrow{alignment} \as \alignment,            
            every node near coord/.append style={font=\tiny,anchor=\alignment}          
        ] 
        table [
           meta index=2
        ]{
             x         y       label  alignment
             0.4    7.24    C-1               0
             0.5    4.42    C-2               0
        };
    \end{semilogyaxis}
    \end{tikzpicture}
    \caption{Text}
    \label{fig:a1}
\end{figure*}

\end{document}
1

You need to set the mark options instead of the options for the whole axis. You also don't need to load both pgfplots and pgfplotstable, and you should set your compatibility version of pgfplots with the compat option. You're also loading amsmath twice. In the future, please try to generate minimal examples, with all packages unnecessary to reproduce the problem removed.

\documentclass[a4paper]{article}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{figure*}
    \centering
    \begin{tikzpicture}
    \begin{semilogyaxis}[
        nodes near coords,
        ylabel={time [s]},
        enlargelimits=0.2,
        log basis y=10,
    ]
        \addplot+[
            black,
            mark options={fill=red},
            only marks,
            point meta=explicit symbolic,
            visualization depends on=\thisrow{alignment} \as \alignment,
            every node near coord/.append style={font=\tiny,anchor=\alignment}
        ]
        table [
           meta index=2
        ]{
             x         y       label  alignment
             0.4    7.24    C-1               0
             0.5    4.42    C-2               0
        };
    \end{semilogyaxis}
    \end{tikzpicture}
    \caption{Text}
    \label{fig:a1}
\end{figure*}

\end{document}

enter image description here

  • Thank you - one further question not directly related to this problem if I may - I use abbreviation/codes as C-1, C-2 etc. Is there a way to sneak in arbitrary many legend entries despite of having only 1 set of values? /addlegendentry{} would add only 1 entry as only 1 set of values is present (the red-circle). I want to piggy back the legend-system to provide a human readable version of my abbreviations. Is this possible? – toobee Apr 30 '15 at 15:54
  • You can use \addlegendimage{empty legend}\addlegendentry{} pairs... see page 217 of the v1.12 manual for more details. If you have other questions about that, its probably best to ask a new question :-) – darthbith Apr 30 '15 at 16:23

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.