MATLAB: Does the legend display lines that look different when using the “stairs” function as opposed to using “plot” in MATLAB R2016b on Linux

MATLAB

In MATLAB R2016b, I'm trying to use the subplot command to generate 2 different plots. One plot using the "stairs" function and one plot using the "plot" function. When adding legends to both plots, the legend for the "stairs" plot seems to render poorly. The line on the legend corresponding to the second line plotted seems to be a slightly different color and line thickness than the line on the plot itself.

Best Answer

It seems the underlying issue is that "stair" plots use "AlginVertexCenters" on its "LineStrip" primitive, which creates crisper and slightly darker lines.  The legend icons do not use "AlignVertexCenters" because doing so would create a color inconsistency for most plots.
The workaround for this particular case is to turn off "AlignVertexCenters" on the stair plot.  
For example,
s=stairs(1:10);
s.Edge.AlignVertexCenters = 'off';
Note: This is undocumented functionality and is therefore subject to change at any time.
Another potential workaround is to render graphics using "software opengl" instead of "hardware opengl".
In order to switch to software opengl in Linux, you will need to start MATLAB with the -softwareopengl flag set. The following is how it would look in the terminal:
matlab -softwareopengl
To set your preferences so that MATLAB always starts with software opengl on this computer, execute this command at the MATLAB command line:
>> opengl('save','software')