Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would I plot the PDF (probability density function) of WeibullDistribution[1/5, 50], WeibullDistribution[1/4, 40], WeibullDistribution[1/3, 30] and WeibullDistribution[1/2, 20] in the same graph?

share|improve this question
There are good examples how to do this in the documentation of the {WeibullDistribution} – Matariki May 1 '12 at 0:51
up vote 8 down vote accepted

Here is a simple way. The Evaluate is needed to ensure the line colors are different (see this question for an explanation of this).

  PDF[WeibullDistribution[1/#, 10 #], x] & /@ Range[2, 5]], {x, 0.1, 5}]

enter image description here

As noted in the documentation, Plot and related functions quite happily draw multiple lines if they are given a list of functions (or data in the case of ListPlot and friends) as their first argument.

Notice the use of Map (/@) and a pure function to avoid having to type out the WeibullDistribution bit of the code multiple times. (This page in the documentation will be useful in this regard.)

share|improve this answer
Thank you for the link to the Map documentation, that is very useful! In this case you used "#" for both parameters. But, let's say I would want to map 1 list of values to the first parameter, and one to the second parameter, how would I do this? – Chris May 1 '12 at 1:05
@Chris You should look up Apply (@@) and apply at level 1 (@@@). A simple example which you can extend to your case is the following: Clear[f];f[#1, #2] & @@@ Transpose[{Range[5], Range[6, 10]}] – R. M. May 1 '12 at 1:10
@Chris: Also have a look at MapThread. But this is really a separate question. – Verbeia May 1 '12 at 1:11

Another way to write Verbeia's code:

Plot[#, {x, 0.1, 5}] & @
  Array[PDF[WeibullDistribution[1/#, 10 #], x] &, 4, 2]
share|improve this answer

Your Answer


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.