Group Abstract Group Abstract

Message Boards Message Boards

0
|
4K Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Using MapThread to Plot and Show two distributions together

I can produce a list of Plots, no problem, with this line of code

MapThread[
 Plot[PDF[NormalDistribution[#1, #2], x], {x, -4, 4}] &, {{0, .1}, {1,
    1.5}}]

List of twoPDFs

But this code

MapThread[
 Show[Plot[
    PDF[NormalDistribution[#1, #2], x], {x, -4, 4}]] &, {0, .1}, {1, 
  1.5}]

Does not produce both plots in the same graphic.

POSTED BY: Roger J Brown
5 Replies

AHA!! Thanks I should be fine now with all the other options.

POSTED BY: Roger J Brown

You can also do the Map within the plot, that way you don't need Show.

Plot[Evaluate[
  PDF[NormalDistribution[#[[1]], #[[2]]], x] & /@ 
   Thread[{{0, .1}, {1, 1.5}}]], {x, -4, 4}, PlotStyle -> {Blue, Red}]

or

Plot[Evaluate[
  PDF[NormalDistribution[##], x] & @@@ {{0, 1}, {0.1, 1.5}}], {x, -4, 
  4}, PlotStyle -> {Blue, Red}]
POSTED BY: Martijn Froeling
Show[MapThread[
  Plot[PDF[NormalDistribution[#1, #2], x], {x, -4, 4}, 
    PlotStyle -> #3] &, {{0, .1}, {1, 1.5}, {Blue, Red}}]]
POSTED BY: Gianluca Gorni

That works just swell, Thanks. But I tried to put PlotStyle everywhere I could think of and it would not thread the colors.

Show[MapThread[
  Plot[PDF[NormalDistribution[#1, #2], x], {x, -4, 
     4}] &, {{0, .1}, {1, 1.5}}], PlotStyle -> {Blue, Red}]
POSTED BY: Roger J Brown

This way:

Show[MapThread[Plot[PDF[NormalDistribution[#1, #2], x],
    {x, -4, 4}] &,
  {{0, .1}, {1, 1.5}}]]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard