作者chungyuandye (養花種魚數月亮賞星星)
看板Mathematica
標題Re: [投稿]經典圖型-物理-Chaos- Marion 5th ed-fi …
時間Thu Jul 7 18:21:02 2011
※ 引述《kichigop (超痛恨不求甚解...XXX)》之銘言:
: Legend部分現學現賣用戴老師教給大家的
: 但是顏色有點怪怪的(還請老師指教),程式部分相當拙劣,是剛學Mathematica時寫的
: 請大家多多包涵
: 不過重點是畫完圖我發現書上的兩條線好像應該對調
: 這一小節主要是在講Chaos的產生與initial conditions有很大的關係(蝴蝶效應)
: 並且在這個example 4.3中利用一個noliear eqation給予不同的I.C.來驗證
: 結果得到fig. 4-24。
: (分隔線以下直接複製即可...我是用Mathematica 7.0版)
: ===================================================================
: (*The two plots in Marion's textbook should be exchanged!!!*)
: (* The nonlinear equation is:
: Subscript[x, n+1]=\[Alpha] Subscript[x, n](1-Subscript[x, n]^2) \
: *)
: mylegend[plot_Graphics, legend_List] :=
: Block[
: {p = plot, l = legend, color, temp},
: color = Cases[p, Hue[a_, b_, c_] :> Hue[a, b, c], Infinity];
: temp = {color[[#]], l[[#]]} & /@ Range[Length@color];
: Labeled[p,
: Grid[{Graphics[{#[[1]], Thickness[0.1], Line[{{0, 0}, {1, 0}}]},
: ImageSize -> {24, 24}, AspectRatio -> 24/24,
: ImagePadding -> 0], #[[2]]} & /@ temp], {Top}]
: ]
: (*以上為戴老師的Legend*)
: \[Alpha] = 2.5;
: recip[x_] := \[Alpha] x (1 - x^2);
: chaos1 = NestList[recip, 0.700000000, 50];(*blue*)
: recip[x_] := \[Alpha] x (1 - x^2);
: chaos2 = NestList[recip, 0.700000001, 50];(*red*)
: p1 = ListPlot[
: {chaos1, chaos2},
: PlotRange -> {0, 1},
: Joined -> True,
: PlotStyle -> {{RGBColor[0, 0, 1],
: Thickness[.003]}, {RGBColor[1, 0, 0], Thickness[.002]}},
: BaseStyle -> {FontFamily -> "Helvetica", FontSize -> 15,
: FontWeight -> "Bold"}];
: mylegend[p1, {"0.700000000", "0.700000001"}]
稍微做一下修改,有些事情用動畫比較能夠讓人了解
Chaos[inita_, initb_, iter_] :=
Block[{ita = inita, itb = initb, n = iter, recip, \[Alpha]},
\[Alpha] = 2.5;
recip[x_] := \[Alpha] x (1 - x^2);
ListLinePlot[
Transpose@
NestList[{recip[#[[1]]], recip[#[[2]]]} &, {ita, itb}, iter],
PlotStyle -> {{Blue, Thickness[.003]}, {Red, Thickness[.002]}},
Frame -> True,
BaseStyle -> {FontFamily -> "Helvetica", FontSize -> 15,
FontWeight -> "Bold"}, PlotRange -> {{0, 100}, {0, 1.1}}]
]
Manipulate[
mylegend[Chaos[0.700000000, 0.7000000001, x],
{"0.700000000", "0.7000000001"}],
{{x, 2, "Time"}, 2, 100, 1}]
--
養花種魚數月亮賞星星
http://chungyuandye.twbbs.org
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 120.119.96.8
推 kichigop:讚! 然後那個顏色我找到原因了,老師是用Hue[],我是用 07/07 19:13
→ kichigop:RGBColor[],同樣數直對這兩個函數對應到的是不同的顏色 07/07 19:14
→ kichigop:把Hue[]改成RGBColor[]就可以顯示相對應正確的顏色 07/07 19:14
推 kichigop:就好像上面shengwey版友的Jet這個colormap重新定義某數值 07/07 19:17
→ kichigop:在新定義的JetColor function中所應表現的顏色 07/07 19:18