找回密码
 注册
Simdroid-非首页
查看: 336|回复: 14

[图形图像] 2D作图例子

[复制链接]
发表于 2008-5-25 00:55:49 | 显示全部楼层 |阅读模式 来自 美国
主要是想画比较好的两维图,这样可以代替Origin 或者Kaleiggraph.

p2=ListPlot[Table[{k,
   PDF[BinomialDistribution[50, p], k]}, {p, {0.3, 0.5, 0.8}}, {k, 0,
   50}], Filling -> {1 -> {0,
     Directive[Red, Thick, Dashed, Opacity[0.4]]},
   2 -> {Axis, Directive[Purple, Dotted, Thick]}, 3 -> {Axis, Blue}},
FrameStyle -> Directive[Arrowheads[0.05], Thick, 12],
FillingStyle -> Directive[Thick, Dashed],
PlotStyle -> {Red, Directive[PointSize[Medium], Purple], Blue},
PlotMarkers -> {Automatic, Medium},
FrameLabel -> {Text[Style["k", Bold, 24]],
   Text[Style["PDF", Bold, 20]]}, AxesOrigin -> {0, 0},
ImageMargins -> {{10, 10}, {10, 10}},
Epilog -> {PointSize[0.02], Point[{0, 0}],
   Text[Style["p=0.3", Italic, Bold, 16], {15, 0.13}, {0, 0}, {1, 0}],
    Text[Style["p=0.5", Italic, Bold, 16], {25, 0.13}, {0, 0}, {1,
     0}], Text[
    Style["p=0.8", Italic, Bold, 16], {45, 0.13}, {0, 0}, {1, 0}]},
PlotLabel ->
  Style["BinomialDistribution Plot",
   Directive[Pink, FontFamily -> "Helvetica", 24, Bold]],
Frame -> True, ImageSize -> 400]
Export["C:/p2.eps", p2, ImageResolution -> 200]
Export["C:/p2.gif", p2, ImageResolution -> 200]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×

评分

1

查看全部评分

发表于 2008-5-26 08:45:29 | 显示全部楼层 来自 江苏无锡
Simdroid开发平台
Good plot, Check legend may help on the label indicate.
回复 不支持

使用道具 举报

发表于 2008-5-26 14:30:54 | 显示全部楼层 来自 江苏无锡
one question

What is difference between BinomialDistribution and NormalDistribution ?
回复 不支持

使用道具 举报

 楼主| 发表于 2008-5-26 18:46:24 | 显示全部楼层 来自 美国
Mathematica里的PlotLegend的例子也比较一般,网上讨论区里说Mathematica的PlotLegend有点问题。
不过那个Epilog和Prolog的功能比较强,可以随便来加任何图标。
Code:
plmarkers = {{"\[FilledCircle]", Medium}, {"\[FilledSquare]",
    Medium}, {"\[FilledDiamond]", Medium}};
p2 = ListPlot[
  Table[{k,
    PDF[BinomialDistribution[50, p], k]}, {p, {0.3, 0.5, 0.8}}, {k, 0,
     50}], Filling -> {1 -> {0,
      Directive[Red, Thick, Dashed, Opacity[0.4]]},
    2 -> {Axis, Directive[Purple, Dotted, Thick]}, 3 -> {Axis, Blue}},
   FrameStyle -> Directive[Arrowheads[0.05], Thick, 12],
  FillingStyle -> Directive[Thick, Dashed],
  PlotStyle -> {Red, Directive[PointSize[Medium], Purple], Blue},
  PlotMarkers -> plmarkers,
  FrameLabel -> {Text[Style["k", Bold, 24]],
    Text[Style["PDF", Bold, 20]]}, AxesOrigin -> {0, 0},
  ImageMargins -> {{10, 10}, {10, 10}},
  Epilog -> {PointSize[0.02], Point[{0, 0}],
    Text[Style["p=0.3", Italic, Bold, 16], {15, 0.13}, {0, 0}, {1,
      0}], Text[
     Style["p=0.5", Italic, Bold, 16], {25, 0.13}, {0, 0}, {1, 0}],
    Text[Style["p=0.8", Italic, Bold, 16], {45, 0.13}, {0, 0}, {1,
      0}]}, Prolog ->
   Inset[Framed@
     Graphics[{Text[Style["\[FilledCircle]", Red], {0, 0}, {1, 0}],
       Text[Style["p=0.3", Italic, Bold, 10], {8, 0}, {1, 0}],
       Text[Style["\[FilledSquare]", Purple], {0, -1}, {1, 0}],
       Text[Style["p=0.5", Italic, Bold, 10], {8, -1}, {1, 0}],
       Text[Style["\[FilledDiamond]", Blue], {0, -2}, {1, 0}],
       Text[Style["p=0.5", Italic, Bold, 10], {8, -2}, {1, 0}]},
      ImageSize -> 40, AspectRatio -> 1], {6, 0.1}, {0, 0}, 10],
  PlotLabel ->
   Style["BinomialDistribution Plot",
    Directive[Pink, FontFamily -> "Helvetica", 24, Bold]],
  Frame -> True, ImageSize -> 400]


另外一个例子:
funct[x_] := Exp[-x/10] - Cos[30 x] Exp[-3 x]
short = Plot[funct[x], {x, 0, 1}, Frame -> True];
Plot[funct[x], {x, 0, 50}, Frame -> True,
Prolog -> {Inset[short, {35, 1.1}, Center, ImageScaled[{0.5, 0.5}]],
   Inset[Text[
     Style["Figure 1. Inset Function", Bold, 16]], {25, -0.5},
    Center]}, PlotRangeClipping -> False, PlotRange -> Full,
ImageMargins -> {{10, 10}, {10, 10}},
ImagePadding -> {{20, 10}, {65, 10}}]
file:///C:/DOCUME%7E1/bing/LOCALS%7E1/Temp/moz-screenshot.jpg

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×

评分

1

查看全部评分

回复 不支持

使用道具 举报

 楼主| 发表于 2008-5-26 19:13:27 | 显示全部楼层 来自 美国
BinomialDistribution[n,p] represents a binomial distribution with n trials and success probability p.
Mean is np, and variance is n(1-p)p.
NormalDistribution[\[Mu],\[Sigma] represents a normal (Gaussian) distribution with mean \[Mu] and standard deviation \[Sigma].
Source: Mathematica Documentation Center
我不做统计的,只是用了Mathematica的一个例子来画图罢了。
我做材料工程,一般就用Mathematica和ABAQUS。原来把Mathematica的结果用Export输出后用Kaleigraph来画图,偶尔用Matlab的script画比较多类似的图。觉得用的软件种类太多,如果离开学校了,买都买不起,所以想把Mathematica用精通一些,或者就用免费的Gnuplot。Gnuplot也不错的,连DOS6下面都可以用,写batch文件也很容易。
回复 不支持

使用道具 举报

发表于 2008-5-27 10:45:51 | 显示全部楼层 来自 江苏无锡
I think PlotLegend is a kind of Epilog, but that's already programmed.
I don't recommend "Show" to combined graphics, GraphicsGrid is better.
回复 不支持

使用道具 举报

 楼主| 发表于 2008-5-27 11:03:28 | 显示全部楼层 来自 美国
It's possible that PlotLegend has been programmed. However, it did not work well (or it has unreleased secret).Mmany questions have been raised about PlotLegend in Google group 'cause almost few people felt satisfied with PlotLegend function.

You can try and show me a nice example.
回复 不支持

使用道具 举报

 楼主| 发表于 2008-5-27 11:04:55 | 显示全部楼层 来自 美国
Computer got nuts. I replied a repeated one.  So I put one more to fix it.

x, y 坐标互换。
Code:
risk[a_, b_, c_][x_] := a x^2 - 2 b x + c
Plot[risk[1, 2, 3][x], {x, -3, 7}, Frame -> True,
FrameLabel -> {x, y}, Axes -> False, PlotLabel -> "Minizing Risk",
ImageSize -> 200]
ParametricPlot[{risk[1, 2, 3][x], x}, {x, -3, 7}, Frame -> True,
FrameLabel -> {y, x}, Axes -> False, PlotLabel -> "Minizing Risk",
ImageSize -> 400]


[ 本帖最后由 smarten 于 2008-5-27 11:10 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
回复 不支持

使用道具 举报

发表于 2008-5-27 11:31:07 | 显示全部楼层 来自 江苏无锡
1. Check HELP search " PlotLegends/tutorial/PlotLegends"

2. Check below code for your information.
游客,本帖隐藏的内容需要积分高于 1 才可浏览,您当前积分为 0


I think all package or intergated function is a kind of programming developed by Mathematica team or other programmers.

[ 本帖最后由 FreddyMusic 于 2008-5-27 11:32 编辑 ]
回复 不支持

使用道具 举报

发表于 2008-5-27 11:55:53 | 显示全部楼层 来自 江苏无锡
Browns google group is not much helpful for me, I perfer Mathematica Blog and demonstration project.

I don't quite satisfied with Plotlegend package, it's quite tight. However, that's better than none option.
回复 不支持

使用道具 举报

发表于 2008-5-27 16:11:01 | 显示全部楼层 来自 安徽合肥
okokok
回复 不支持

使用道具 举报

 楼主| 发表于 2008-5-27 22:08:31 | 显示全部楼层 来自 美国
Also the PlotLegend function you gave does not provide the position option, sometime the legend sits on the top of curves.  Even when I adjust the figure size by dragging or specify with ImageSize option, the legend easily messes up with the plots.

The general idea is to specify marker (including point markers or line markers) and notation, location, size, font related specs.  It is pretty complex.  So it is better for Mathematica to provide some nice examples to illustrate the methods so that everyone can plotting with his own taste.

[ 本帖最后由 smarten 于 2008-5-27 22:16 编辑 ]
回复 不支持

使用道具 举报

发表于 2008-5-28 16:58:05 | 显示全部楼层 来自 江苏无锡
you can control at PlotLegend with LegendPosition.
回复 不支持

使用道具 举报

发表于 2008-6-14 19:07:54 | 显示全部楼层 来自 山东东营

回复 3# 的帖子

What is difference between BinomialDistribution and  NormalDistribution?
the BinomialDistribution can transform  NormalDistribution in math at certain condition.
you can prfer books on probability.
回复 不支持

使用道具 举报

发表于 2010-12-8 16:40:38 | 显示全部楼层 来自 天津
很好,学习了!
lz太厉害了
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-5-3 16:19 , Processed in 0.052828 second(s), 18 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表