5
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ Also see the last part of my answer to plotting in grayscale $\endgroup$ Commented May 4, 2012 at 3:55

4 Answers 4

11
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Thank you very much! $\endgroup$ Commented May 4, 2012 at 5:17
7
$\begingroup$

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[].

$\endgroup$
1
  • $\begingroup$ 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[]. $\endgroup$ Commented May 4, 2012 at 3:53
7
$\begingroup$

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.

$\endgroup$
0
7
$\begingroup$

The Monochrome plot theme was made for this. It uses black curves with different types of dashing to distinguish the functions:

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

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.