Thread Subject: contour plot with dashed linespec

Subject: contour plot with dashed linespec

From: Paul Ullrich

Date: 8 Sep, 2009 21:34:04

Message: 1 of 4

Hi all,

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?

Subject: contour plot with dashed linespec

From: Brendan

Date: 8 Sep, 2009 23:45:22

Message: 2 of 4

On Sep 8, 6:34 pm, "Paul Ullrich" <ayca...@gmail.com> wrote:
> Hi all,
>
> 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.

Subject: contour plot with dashed linespec

From: Paul Ullrich

Date: 9 Sep, 2009 02:26:10

Message: 3 of 4

Brendan <brendandetracey@yahoo.com> wrote in message <b2ecbdf8-190b-4abd-a9d4-5a08a20f6e21@o21g2000vbl.googlegroups.com>...
> On Sep 8, 6:34?pm, "Paul Ullrich" <ayca...@gmail.com> wrote:
> > Hi all,
> >
> > 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?

Subject: contour plot with dashed linespec

From: Brendan

Date: 9 Sep, 2009 12:37:19

Message: 4 of 4

On Sep 8, 11:26 pm, "Paul Ullrich" <ayca...@gmail.com> wrote:
> Brendan <brendandetra...@yahoo.com> wrote in message <b2ecbdf8-190b-4abd-a9d4-5a08a20f6...@o21g2000vbl.googlegroups.com>...
> > On Sep 8, 6:34?pm, "Paul Ullrich" <ayca...@gmail.com> wrote:
> > > Hi all,
>
> > > 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?- Hide quoted text -
>
> - Show quoted text -

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.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
contour Paul Ullrich 8 Sep, 2009 17:39:03
linespec Paul Ullrich 8 Sep, 2009 17:39:03
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com