Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am going to plot for instance:

Plot[Evaluate[
   PDF[ExponentialDistribution[#]][x] & /@ {1/2, 1/5, 1/25, 
      1/1000}], {x, 0, 50}, AxesOrigin -> {0, 0}]

Now, when someone prints this black and white, I would want him to be able to distinguish between the curves (a line, then a dotted line and so on). How would you suggest me to change the code, to achieve this goal?

share|improve this question
    
Also see the last part of my answer to plotting in grayscale –  rm -rf May 4 '12 at 3:55
add comment

3 Answers

up vote 7 down vote accepted

In addition to Dashing, there are also DotDashed and Dotted line styles. So you could define a set of plot styles as follows, varying first the dashing and second the gray shade:

styles = Flatten@
  Table[{Directive[color], Directive[Dashed, color], 
    Directive[DotDashed, color], 
    Directive[Dotted, color]}, {color, {Black, Gray}}]

Then the plot that is supposed to be printed in black and white would be created by this:

p = Plot[Evaluate[
   PDF[ExponentialDistribution[#]][x] & /@ {1/2, 1/5, 1/25, 
     1/1000}], {x, 0, 50}, AxesOrigin -> {0, 0}, PlotStyle -> styles]

Line styles

share|improve this answer
    
Thank you very much! –  Chris May 4 '12 at 5:17
add comment

Here's one quick way:

plot = Plot[Evaluate[
    PDF[ExponentialDistribution[#]][x] & /@ {1/2, 1/5, 1/25, 
      1/1000}], {x, 0, 50}, AxesOrigin -> {0, 0}, Frame -> True];
cols = Cases[plot, _Hue, Infinity];
plot /. Thread[cols -> Map[Dashing, {{}, Tiny, Small, Medium}]]

dashed plots

In general, you can replace the Map[Dashing, {{}, Tiny, Small, Medium}] in the last line with a list of plotting styles whose length is the same as the number of function you originally plotted. If you want to use a compound style (e.g. you want the curve to be slightly thicker as well as dashed), you will want to use Directive[] in conjunction with Thickness[]/AbsoluteThickness[] and Dashing[]/AbsoluteDashing[].

share|improve this answer
    
Note: this is for the case where you've already generated a color version, and you want a monochrome one. If you are generating a monochrome one from the outset, use the PlotStyle option of Plot[]. –  J. M. May 4 '12 at 3:53
    
Thank you very much! –  Chris May 4 '12 at 5:16
add comment

You could also generate your plot, and then click multiple times to select the various curves, and set the dashing pattern via the Graphics > Drawing Tools palette. Under the section for Stroke, you have some additional patterns.

For example: Dashing[{0, Small, 0, Small, Medium, Small}] which is a -..-..-..- pattern.

share|improve this answer
    
Thank you very much! –  Chris May 4 '12 at 5:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.