1

I'm trying to draw a graph from a table were I have these data:

DIM AVRG1 MAX1 MIN1 AVRG2 MAX2 MIN2

So I would like to draw 6 lines in my graph:

  • 2 means
  • 2 for the maximum values
  • 2 for the minimum values

Moreover I'd like to "mark" the means with a stronger color, like blue and red, and give the other two a different color wich is less strong, for example cyan or orange.

So I included

\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}

Letting tikz take care of loading xcolor I passed it the following options:

\PassOptionsToPackage{usenames,dvipsnames}{xcolor}

If I try to load xcolor by itself I get an error while this way works fine.

Then I take the values from the file this way:

\begin{tikzpicture}
    \begin{axis}[width=\linewidth, xmin=0, xmax=8192, ymin=0]
        \addplot [thick, blue] table [mark=none, y=AVRG1, x=DIM]{time1-CPU.data};
        \addplot [small, cyan]table [mark=none, y=MAX1, x=DIM]{time1-CPU.data};
    \end{axis}
\end{tikzpicture}

This does work because cyan is in tikz [2]. But let's suppose that instead of cyan I'd like to use Cerulean which is xcolor [1], then I get the following error:

 Package pgfkeys Error: I do not know the key '/tikz/Cerulean' and I am going to ignore it. Perhaps you misspelled it

How can I make it work? Thank you!

EDIT: Here is an example

\documentclass[epsfig,a4paper,11pt,titlepage,twoside,openany]{book}
\usepackage{epsfig}
\usepackage{plain}
\usepackage{setspace}
\usepackage[paperheight=29.7cm,paperwidth=21cm,outer=1.5cm,inner=2.5cm,top=2cm,bottom=2cm]{geometry} 
\usepackage{titlesec}

\usepackage[utf8x]{inputenc} 

\singlespacing

\usepackage[italian]{babel}

\usepackage{ulem} 
\usepackage{amsmath} 
\usepackage{array}
\usepackage{multirow} 
\setcounter{secnumdepth}{5} 
\usepackage{caption}
\usepackage{pgfplotstable}
\usepackage{pgfplots}
\usepackage{pgfmath}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true, linktocpage=true, pdfstartpage=1, pdfstartview=FitV,
    breaklinks=true, pdfpagemode=UseNone, pageanchor=true, pdfpagemode=UseOutlines,
    plainpages=false, bookmarksnumbered, bookmarksopen=true, bookmarksopenlevel=1,
    hypertexnames=true, pdfhighlight=/O,
    urlcolor=black, linkcolor=black, citecolor=black,
} 
\PassOptionsToPackage{usenames,dvipsnames}{xcolor}

\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usetikzlibrary{arrows,automata}
\usegdlibrary{trees}

\usepackage{listings}
\usepackage[cache=false]{minted} 
\setminted{tabsize=4, breaklines, breakanywhere, linenos, mathescape, fontsize=\small}

\definecolor{Ashgrey}{rgb}{0.7, 0.75, 0.71}
\definecolor{Atompurple}{rgb}{0.6, 0.4, 0.8}

\begin{document}
\lstset{
      breakatwhitespace=false,         
      breaklines=true,     
      basicstyle=\footnotesize\ttfamily,            
      commentstyle=\color{Ashgey}, 
      keywordstyle=\color{Atompurple}, 
      language=C++, 
      rulecolor=\color{black}, 
      tabsize=4,
      escapeinside={\%*}{*)},
      morekeywords={compute, from, throw, std, ostringstream, __LINE__, __FILE__, define},
}

  \pagenumbering{gobble} 

  \clearpage
  \clearpage
  \pagestyle{plain} 
  \mainmatter

    \begingroup
      \renewcommand{\cleardoublepage}{} 
      \renewcommand{\clearpage}{} 
      \titleformat{\chapter}
        {\normalfont\Huge\bfseries}{\thechapter}{1em}{}

      \titlespacing*{\chapter}{0pt}{0.59in}{0.02in}
      \titlespacing*{\section}{0pt}{0.20in}{0.02in}
      \titlespacing*{\subsection}{0pt}{0.10in}{0.02in}
      \newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\}

      \begin{center}
        \begin{tikzpicture}
            \begin{axis}[width=\linewidth, xmin=0, xmax=8192, ymin=0, xlabel=\# Clotoidi, ylabel=Tempo medio ($ms$)]
                \addplot [thick, draw=blue] table [mark=none, y=AVRG, x=DIM]{time1-CPU.data};
                \addplot [small, cyan]table [mark=none, y=MAX, x=DIM]{time1-CPU.data};
                \addplot [small, color=Cerulean]table [mark=none, y=MIN, x=DIM]{time1-CPU.data};
            \end{axis}
        \end{tikzpicture}
        \end{center}

    \endgroup



    \titleformat{\chapter}
        {\normalfont\Huge\bfseries}{Allegato \thechapter}{1em}{}
    \appendix

\end{document}

I've left all the packages inside because I don't know if any of them can clash with another (?).

Compiling this gives:

Package xcolor Error: Undefined color `Cerulean'.

And

Package xcolor Error: Undefined color `tikz@color'.

[1] https://en.wikibooks.org/wiki/LaTeX/Colors

[2] https://en.wikibooks.org/wiki/LaTeX/PGF/TikZ#Color

2
  • 4
    Welcome to TeX.SE! Could you please provide us with a complete minimal example, i.e. a small document that starts with \documentclass, ends with \end{document} and illustrates the problem? (And did you try color=Cerulean? You seem to be saying you use \usetikzlibrary{graphdrawing} but the example you use uses pgfplots syntax.)
    – user121799
    Commented Sep 20, 2018 at 7:04
  • Yeah sure, the document is quite big, so I'll try to make a smaller one. I didn't try color=Cerulean I shall try right away, thank you
    – icosac
    Commented Sep 20, 2018 at 7:46

2 Answers 2

2

Here is an example that shows Cerulean works just fine:

enter image description here

Code:

\PassOptionsToPackage{usenames,dvipsnames}{xcolor}
\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}

\begin{document}
\noindent
\begin{tikzpicture}
    \begin{axis}
        \addplot [thick, red,      mark=none] {x+3};
        \addplot [thick, Cerulean, mark=none] {-2*x-4};
    \end{axis}
\end{tikzpicture}
\end{document}
3
  • Ok, solved that, I just had to move \PassOptionsToPackage{usenames,dvipsnames}{xcolor} up... I feel a little bit stupid ahahah... Thanks!
    – icosac
    Commented Sep 20, 2018 at 8:01
  • @icosac: Don't feel stupid, You aren't the first, not the last to make such a mistake. I am sure I have made it many times. Perhaps if you change the title to something along the lines as to where one should place \PassOptionsToPackage that might make it easy for other to locate this question when they have that problem. Commented Sep 20, 2018 at 17:13
  • Yes, sure thing, changing it right now
    – icosac
    Commented Sep 21, 2018 at 7:18
0

You can define your own colours at the start

\definecolor{Blue}{rgb}{0.0,0.0,0.7}
\definecolor{Red}{rgb}{0.7,0.0,0.0}
\definecolor{Green}{rgb}{0.0,0.5,0.0}
\definecolor{Gray}{gray}{0.85}
\definecolor{LightCyan}{rgb}{0.88,1,1}
\definecolor{White}{rgb}{1,1,1}

You must log in to answer this question.

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