1.5.5 Matching R
The plots follow R glmnet 4.1.10’s plotCoef, plot.multnet, plot.mrelnet and plot.cv.glmnet:
The same axes, x-axis labels and y-axis labels, the same defaults for #:xvar and #:sign-lambda, each axis widened by 4% at both ends, and the same colours: the first six of R’s palette for the curves, and red points, dark grey bars and black dotted lines for the cross-validation curve.
The counts along the top of a path plot are R’s: at each tick, the count of the fitted λ next to it, read as R’s approx with method = "constant" reads it. That is the next λ to the right, or to the left for log λ.
A curve is drawn for each predictor that is nonzero at some λ. When no coefficient of a class is nonzero, R draws no plot for it, and neither does plot-coefficient-path. When exactly one is, both warn that the plot is not meaningful; here the warning is logged.
When no coefficient is nonzero at all, R warns and returns without drawing anything. plot-coefficient-path then has no pict to return, and raises an error instead.
R writes the curve labels at half its text size (cex = 0.5); here they are three quarters of plot-font-size, which is easier to read.
A λ of 0 has no place on a log λ axis, and neither R nor plot-coefficient-path draws it. R still puts the curve labels level with the coefficients at that λ, at an infinite position, so that it draws none; here they are level with the ends of the curves as drawn.
The ticks are plot-lib’s, not R’s pretty values, and the error bars’ caps are a fixed number of pixels wide rather than 2% of the x axis.
R writes a count at every λ along the top of the cross-validation plot and leaves out those that would overlap. Here each run of consecutive λ with the same count gets one label, in its middle, and runs whose labels would overlap are left out.
R draws the plots of the classes or responses one after another; plot-coefficient-path stacks them into one pict.