# Very thick line not showing up in black in Tikz picture but shows in red - why?

I think the code below should add a 'very thick' black line from (-1,0) to (0,0), but it doesn't. If I change the color to red, the line shows up but not very thick. Two things I don't understand about this Tikz picture are (a) why the very thick line doesn't show on the axis, and (b) why the red line (when I change color) doesn't overwrite the white circle at (0,0). Confusion (b) is a curiosity I can live with, but I'd like the function for x < 0 to be indicated by a thick line. Here is the code and the output:

\documentclass[11pt,reqno]{amsbook}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
%
\begin{figure}[h]
\begin{tikzpicture}
\begin{axis}
[
axis x line =middle,
axis y line= middle,
xmin=-1,
xmax=3,
ymin=0,
ymax=1.2]
\addplot[very thick] coordinates {(-1,0) (0,0) };
\draw[dashed] (1,0) -- (1,0.39);
\draw (1.4,0.2) node[right] {$p_X(0;q)$};
\draw[very thick] (-1,0) -- (0,0);
% If I change color to red it shows up, but not 'very thick'.
\draw(2,1) node[right]{$F_X(x;q)$};
\draw[dashed] (1,0.43) -- (1,1);
\draw (1.4,0.7) node[right] {$p_X(1;q)$};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}


• You seem to not really plot a function but rather a (small) set of concrete points. I would think that using a plain tikzpicture might be better for this as you don't seem to need pgfplots. Commented Nov 14, 2022 at 7:18
• @Raven: Maybe I should just take the time to create boiler-plate code to create axes with labels and ticks. Commented Nov 14, 2022 at 17:10

The line is actually drawn in black as well, but only the part above the x axis. See the following screenshot of your original code at the 0,0 coordinate zoomed to 5000%:

The reason that the line is not as thick as the others is that pgfplots does not draw lines outside of the plot area, so the 'bottom part' of the line is missing.

To show the full line you can enlarge the plot area a little bit, for example to ymin=-0.015. This will also draw the y-axis line below the plot, but fortunately you have a white filled circle at 0,0 which hides the axis extension.

\documentclass[11pt,reqno]{amsbook}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
%
\begin{figure}[h]
\begin{tikzpicture}
\begin{axis}
[
axis x line =middle,
axis y line= middle,
xmin=-1,
xmax=3,
ymin=-0.015,
ymax=1.2]
\addplot[very thick] coordinates {(-1,0) (0,0) };
\draw[dashed] (1,0) -- (1,0.39);
\draw (1.4,0.2) node[right] {$p_X(0;q)$};
\draw[very thick] (-1,0) -- (0,0);
% If I change color to red it shows up, but not 'very thick'.
\draw(2,1) node[right]{$F_X(x;q)$};
\draw (1.4,0.7) node[right] {$p_X(1;q)$};

The other issue about the white circle not being overwritten by the line probably has something to do with the order in which pgfplots processes and draws \addplot and \draw commands, which is not necessarily the same order as in the list of statements in the code. As the comment by Raven suggests you can also make this plot fully in TikZ itself (see section 22 Plots of Functions in the TikZ manual) which would give you a bit more control about the order of processing and also lets you draw outside of the plot. A disadvantage of this approach is that creating tic marks and labels is a bit more work.