# Change steps of logarithmic scale in PGFPlots and remove markers for selected series

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

xtick={-5,0,5},


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

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.

\documentclass[letterpaper,12pt]{article}
\usepackage[margin=0.5 in,landscape]{geometry}
\usepackage[justification=centering]{caption}
\usepackage[dvipsnames]{xcolor}
\usepackage{pgfplotstable,pgfplots}
%\renewcommand{\familydefault}{\sfdefault}
\usepackage{mathptmx}
%\usepackage{sansmath} % Enables turning on sans-serif math mode, and using other environments
%\sansmath % Enable sans-serif math for rest of document
%\usepackage[math]{blindtext}
\pagestyle{empty}
\pgfplotsset
{
every axis/.append style={semithick},
major tick length=7pt,
minor tick length=3pt,
tick style={semithick,black},
width= \textwidth,
height= \textheight
}

\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{loglogaxis}[
xlabel=Re,
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};‎
‎\addplot table [y=fexpGalv., x=ReGalv., only marks]{\mydata};‎
‎\addplot table [y=fexpCu, x=ReCu, only marks]{\mydata};‎
‎\addplot table [y=fexpPVC, x=RePVC, only marks]{\mydata};‎
\end{loglogaxis}
\end{tikzpicture}
\caption{Friction factors versus Reynolds Number for different pipes}
\end{figure}

\end{document}


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

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.

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. Nov 8, 2016 at 19:44

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
%  <http://tex.stackexchange.com/q/337900>)
\documentclass[letterpaper,12pt]{article}
\usepackage[margin=0.5 in,landscape]{geometry}
\usepackage{pgfplots,pgfplotstable}
\usetikzlibrary{pgfplots.colorbrewer}
\pgfplotsset{
compat=1.3,
every axis/.append style={semithick},
major tick length=7pt,
minor tick length=3pt,
tick style={semithick,black},
width=\textwidth,
height=\textheight,
}
\begin{document}
\pagestyle{empty}
\begin{figure}
\begin{tikzpicture}
\begin{loglogaxis}[
% put xlabel' in math mode because "Re" is a variable
% (same for "f" in ylabel')
xlabel=$Re$,
% 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
xmin=9e3,
xmax=8e4,
ymin=4e-3,
ymax=1.2e-2,
xtickten={4,5},
ytickten={-3,-2,-1},
% 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+ [only marks,Set1-B] table [x=ReGalv.,y=fexpGalv.]    {\mydata};‎
‎\addplot+ [only marks,Set1-C] table [x=ReCu,y=fexpCu]          {\mydata};‎
‎\addplot+ [only marks,Set1-D] table [x=RePVC,y=fexpPVC]        {\mydata};‎

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


• 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? 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? 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. Nov 9, 2016 at 1:12