[Tex/LaTex] pgfplots spline and colorseries do not work

pgfplots

I want to create a plot with predefined colors and have the points connected by a spline curve.

Both things do not happen. The color series is not applied (all lines are black) and a spline is not applied to the curve.

\documentclass[]{scrbook}

\usepackage{pgfplots}
\usetikzlibrary{pgfplots.patchplots}

\definecolor{colorseriesRGB1}{RGB}{0,     0, 192}
\definecolor{colorseriesRGB2}{RGB}{192,   0,   0}
\definecolor{colorseriesRGB3}{RGB}{0  , 128,   0}
\definecolor{colorseriesRGB4}{RGB}{192,   0, 192}

\pgfplotscreateplotcyclelist{colorseries-rgb}{
  {colorseriesRGB1},
  {colorseriesRGB2},
  {colorseriesRGB3},
  {colorseriesRGB4},
}

\begin{document}
\pgfplotsset{width=0.8\textwidth, height=0.6\textwidth}
\begin{tikzpicture}
\begin{axis}[cycle list name=colorseries-rgb]
\addplot[samples = 10,patch type=quadratic spline] {x^2 - x +4};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

EDIT:

My original code is using a datatable. If I add the options mesh,patch,patch type=quadratic spline then the plot looks completely wrong

\begin{tikzpicture}
\begin{axis}[scale only axis,
             every axis plot/.append 
               style={line width=1.5pt},
             mark=none,
             style=solid,
             enlargelimits=false, ymax = 3.5,
             cycle list name=colorseries-office,
             % smooth,
             mesh,patch,patch type=quadratic spline
             ]
  %  column with header  "y1"
  \addplot+   table[x=x1,y=y1]  from  \datatable;
  \addplot+   table[x=x1,y=y2]  from  \datatable;
  \addplot+   table[x=x1,y=y3]  from  \datatable;
  \addplot+   table[x=x1,y=y4]  from  \datatable;
\end{axis}
\end{tikzpicture}

enter image description here

However the option smooth, although I have no idea what it really does looks like what I want:

enter image description here

Best Answer

If you have no optional arguments, then simply using

\addplot {x^2 - x +4};

will inherit the correct styles that you have specified. However, if you wish to override some of the arguments but keep the other aspects (as you have done in your code), then you have to use \addplot+[...

\addplot+[samples = 10] {x^2 - x +4};

which tells pgfplots to use the styles specified in cyclelist, but change the options that you have specified.

See Section 4.6.7 for more examples.

With regards to the quadratic spline, referencing Section 5.6.1,

The quadratic spline is actually nothing but piecewise Lagrangian interpolation with quadratic polynomials: it expects three points in the sequence ‘(left end), (right end), (middle)’ and interpolates these three points with a quadratic polynomial.

As such, for your example you can use something like

% left, right, middle
\addplot+[patch,mesh,patch type=quadratic spline]coordinates{(-5,33)(5,23)(0,3)};

It seems like you're currently trying to feed a function in to help find the coordinates- I don't know how to do this, but perhaps one of the gurus on this site will.