1) So I want my x axis' step size to be increased since it looks very cluttered as it is right now. Unfortunately it's a loglog plot so the usual


doesn't work. At the moment, it looks like this (the main thing inside the chart is omitted for privacy).

enter image description here

My MWE would be this but I guess it won't work without the data file itself which I can provide if needed but I think it's pretty straightforward.

\usepackage[margin=0.5 in,landscape]{geometry}
%\usepackage{sansmath} % Enables turning on sans-serif math mode, and using other environments
%\sansmath % Enable sans-serif math for rest of document
    compat = newest,
    every axis/.append style={semithick},
    major tick length=7pt,
    minor tick length=3pt,
    tick style={semithick,black},
    width= \textwidth,
    height= \textheight
\pgfplotstableread[col sep = comma]{dat.csv}\mydata

    ylabel=Fanning friction factor \textit{f},
    %y label style={rotate=-90},
    legend pos=south west,
    legend columns=1,
    legend style={draw=none}
    %no markers
    ‎\addplot table [y=fexpSS, x=ReSS, mark=only marks]{\mydata};‎
    ‎\addlegendentry{SS Experimental}
    \addplot table [y=fchurchSS, x=ReSS, mark=none]{\mydata};‎
    ‎\addlegendentry{SS Churchill}‎
    ‎\addplot table [y=fexpGalv., x=ReGalv., only marks]{\mydata};‎
    ‎\addlegendentry{Galv. Exp}‎
    ‎\addplot table [y=fchurchGalv., x=ReGalv., mark=none]{\mydata};‎
    ‎\addlegendentry{Galv. Churchill}‎
    ‎\addplot table [y=fexpCu, x=ReCu, only marks]{\mydata};‎
    ‎\addlegendentry{Cu Exp}
    ‎\addplot table [y=fchurchCu, x=ReCu, mark=none]{\mydata};‎
    ‎\addlegendentry{Cu Churchill}‎
    ‎\addplot table [y=fexpPVC, x=RePVC, only marks]{\mydata};‎
    ‎\addlegendentry{PVC Exp}
    ‎\addplot table [y=fchurchPVC, x=RePVC, mark=none]{\mydata};‎
    ‎\addlegendentry{PVC Churchill}‎
    ‎\addplot table [y=blasius, x=RePVC, mark=none]{\mydata};‎
    ‎\addlegendentry{Blasius Equation}‎
    \caption{Friction factors versus Reynolds Number for different pipes}


By the way I would like to control the steps and min/max for my y axis too.

The CSV file can be downloaded here: https://1drv.ms/u/s!AnPuH_uDwkPFgo58-JfHJHs4CE4c6w

2) I would also like to remove the markers from the legend for the series where I have lines (i.e. the 8 series with lines drawn through the points) and would like the lines to be removed from the legend for the 4 series which have only points and no lines. I tried the solution here but it removed all the markers so it's not feasible. Something like what I did in Excel would be fine for example shown below.

enter image description here

3) I want to put a comma before the f here but if I do, it fails to load. Anyone has any ideas?

ylabel=Fanning friction factor \textit{f},
  • It would be nice if you could add some dummy data to your question in the range of your real data, so we, the helpers, don't need to create some. Also this helps to avoid a problem with log axis when no data are present (see here). Nov 8, 2016 at 18:37
  • That is a little difficult in the MWE itself so I have an edit link to the CSV file so you can download and use it.
    – Zack Fair
    Nov 8, 2016 at 19:44

1 Answer 1


For 1) you can use e.g. xtickten + some extra x ticks.
For 2) you almost did it right. You just have to give the "mark" options to the optional argument of \addplot and not to the optional argument of table.
For 3) you just have to surround the label by curly brackets so the comma isn't misinterpreted as separator for the options.

Then I did some more small changes. For that, have a look at the comments in the code.

(The remaining issue now is, that the "Cu Churchill" line is laying almost completely behind the "PVC Churchill" line. This could be avoided e.g. by moving the dashed to the "PVC Churchill" or by using dashed and dotted lines for the last two lines.)

% used PGFPlots v1.14
% (the data file must be downloaded from the link in the question
%  <http://tex.stackexchange.com/q/337900>)
\usepackage[margin=0.5 in,landscape]{geometry}
        every axis/.append style={semithick},
        major tick length=7pt,
        minor tick length=3pt,
        tick style={semithick,black},
                \pgfplotstableread[col sep=comma]{dat.csv}\mydata
                % put `xlabel' in math mode because "Re" is a variable
                % (same for "f" in `ylabel')
                % to use a comma inside the label, surround the label in brackets
                % so the comma isn't misinterpreted being an option separator
                ylabel={Fanning friction factor, $f$},
                legend pos=south west,
                legend columns=1,
                legend style={draw=none},
                % added min and max values to know where to put the extra tick labels
                % added (main) ticks
                % added extra ticks at the ends of the axes
                extra x ticks={9e3,8e4},
                extra y ticks={4e-3,1.2e-2},
                % use ColorBrewer cycle list
                cycle list/Set1-4,
                % moved "mark" options to the optional argument of `\addplot'
                % and added colors manually, so they match for the same "set"
                ‎\addplot+ [only marks,Set1-A] table [x=ReSS,y=fexpSS]          {\mydata};‎
                \addplot+ [mark=none,Set1-A]  table [x=ReSS,y=fchurchSS]       {\mydata};‎
                ‎\addplot+ [only marks,Set1-B] table [x=ReGalv.,y=fexpGalv.]    {\mydata};‎
                ‎\addplot+ [mark=none,Set1-B]  table [x=ReGalv.,y=fchurchGalv.] {\mydata};‎
                ‎\addplot+ [only marks,Set1-C] table [x=ReCu,y=fexpCu]          {\mydata};‎
                ‎\addplot+ [mark=none,Set1-C]  table [x=ReCu,y=fchurchCu]       {\mydata};‎
                ‎\addplot+ [only marks,Set1-D] table [x=RePVC,y=fexpPVC]        {\mydata};‎
                ‎\addplot+ [mark=none,Set1-D]  table [x=RePVC,y=fchurchPVC]     {\mydata};‎
                ‎\addplot+ [mark=none,Set1-D,dashed]  table [x=RePVC,y=blasius] {\mydata};‎

                % moved legend here because (I think) it is much more clearly arranged
                    SS Experimental,
                    SS Churchill,‎
                    Galv. Exp,‎
                    Galv. Churchill,‎
                    Cu Exp,
                    Cu Churchill,‎
                    PVC Exp,
                    PVC Churchill,‎
                    Blasius Equation,
        \caption{Friction factors versus Reynolds Number for different pipes}

image showing the result of above code

  • Wow that's an awesome solution. Just curious where you defined the cycle list Brewer thing since I might try to play with the black white cycle list here (tex.stackexchange.com/questions/134346/…) since B&W is more professional and try to have circles, crosses, etc instead of different colored circles. Edit: Nevermind I found the line. But where do you get the color cycles from and how would you use black white instead of that if at all possible?
    – Zack Fair
    Nov 8, 2016 at 21:05
  • For predefined cycle lists and how you can create them on your own, have a look at section 4.7.7 in the PGFPlots manual on page 210ff (v1.14). (And in the colorbrewer library there are more color cycle lists, which isn't what you are searching for now.) To use only black, white and maybe gray as colors you will get inspired by the default cycle lists. But actually I didn't use the cycle list in my solution, but had to load the colors to then be able to use them as arguments for the \addplots. Nov 8, 2016 at 21:29
  • Ah OK thanks will do. For now though I love the solution, especially the matching colors. Any way to make the Blasius one different though, since it's not really for any specific one?
    – Zack Fair
    Nov 8, 2016 at 21:33
  • Besides giving it another line style you could - in addition - give it another color. To do so replace cycle list/Set1-4 with cycle list/Set1-5 and use Set1-E instead of Set1-D for the "Blasius" \addplot. Or even better just use black or gray as color. Nov 8, 2016 at 21:46
  • I see. That worked. Thanks. Do you know how to regress the 4 curves instead of connecting by lines? Doing it in normal non-log axes is fine too. I have seen a question similar (tex.stackexchange.com/questions/118972/…) but it has its data as columns in the file, not the way we defined it with x=ReSS, y=fexpSS and all.
    – Zack Fair
    Nov 9, 2016 at 1:12

You must log in to answer this question.

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