I've recently been plotting fluid flows using MATLAB's contour command and wanted to separately identify contour lines of positive and negative using solid and dashed linespec, respectively. I have been using the following command to do so:
contour(Lon, Lat, Ubig, 'LevelList', 1e-5*[1:2:15], 'LineColor', 'black', 'ShowText', 'off');
hold on;
contour(Lon, Lat, Ubig, '--', 'LevelList', 1e-5*[-15:2:-1], 'LineColor', 'black', 'ShowText', 'off');
hold off;
However, using these commands the negative contour lines actually appear solid in my plots:
http://www-personal.umich.edu/~paullric/BadPlot.png
I can use : as a linespec instead, in which case I get
http://www-personal.umich.edu/~paullric/DotPlot.png
which at least lets me identify the negative regions, but is harder to read. Is there any way I can fix this?
Since you are not using colours, I presume you have the need to print
on a non-colour printer. Try using a different renderer for your
figures.
set(gcf, 'Renderer', 'painters')
set(gcf, 'Renderer', 'zbuffer')
set(gcf, 'Renderer', 'opengl')
Trying a different renderer can effect how dashed line patterns
appear. Try using zbuffer and then print -dpng -r300 myfig.png
Using painters with a postscript file can make dots appear very small
(iirc on windows at least).
Back in the day, being able to set customised dash line patterns was
one of the (very) few advantages of NCAR graphics. Wish Matlab could
do the same.
Thanks for the suggestion. The dashed lines look perfect using either zbuffer or opengl, but if I try to export the resulting image to a eps file or pdf file the lines are not smooth (unlike with the painters renderer). Thoughts?
You are pretty much stuck with bad dots when exporting to a vector
format like postscript, eps, pdf etc. Your only solution is to export
to a bitmap format, as I stated above. You could also try one of the
other two dashed line patterns. If you are not opposed to gray scale,
then you could first use contourf with a two colour colourmap. Sample:
z = peaks(100);
colormap([0.9 0.9 0.9 ; 1 1 1])
contourf(z,'LineStyle','none');
caxis([-10 10])
hold on
contour(z,[0:8],'k');
[c,h] = contour(z,[-8:0]);
set(h,'LineStyle',':','LineColor','k')
contour(z,[0 0],'k','LineWidth',2);
hold off
With this, for the negative lines you might not even want a dashed
line style, or you might set them to white. You have to play around to
find what looks best. Try making the dashed lines thicker, or use
heavier lines to denote positive values.