2017-08-25 56 views
1

plot1 = ListPlot[MNvsAmp, PlotRange -> All, PlotStyle -> PointSize[Large], ImagePadding -> 85, Frame -> {True, True, True, False}, FrameLabel -> {"Time, s", "Number of atoms, 1000"}, PlotMarkers -> {marker1, .035}, PlotLegends -> "gamma = 1.903 beta = 2.173*10^(-20)"];我想積2個listplots並在一個座標系統中的一個擬合曲線,但疊加功能顯示我這樣的結果

plot2 = ListPlot[TvsTXTvalue, PlotRange -> All, PlotStyle -> PointSize[Large], ImagePadding -> 85, Frame -> {False, False, False, True}, FrameTicks ->{None, None, None, All}, FrameLabel -> {{"","Temperature, mK"},{"",""}}, PlotMarkers -> {marker2, .035}, PlotLegends -> "gamma = 1.903 beta = 2.173*10^(-20)"];

plot3 = Plot[Normal[bettafit], {tt, 3.7, 4.4}, PlotStyle -> Directive [Thick], Axes -> {False, False}]

Overlay[{plot1, plot2, plot3}]

this is the result I get, the curve is somewhere where it shouldn't be

enter image description here

+2

您是否嘗試過'展會[{plot1,plot2,plot3}]'? – halirutan

+1

'Overlay'將圖形座標系中的東西對齊,而不是繪圖系統。幾乎沒有你想要的東西(我不認爲我曾經使用過「Overlay」)這很奇怪,文檔不清楚它,甚至沒有指出你在'See''下的'Show'' – agentp

+0

不幸的是, 「表演」不會讓我在不同的尺度上對他們進行繪製。 –

回答

1

適應Jason B's code

d1 = {{2, 6.4}, {4, 5.5}, {7, 4.6}, {9, 4.5}}; 
d2 = {{1.4, 32.4}, {3.4, 25.5}, {6.7, 20.6}, {8.9, 21.5}}; 
fit = Fit[d1, {1, x, x^2}, x]; 

TwoAxisListPlot[{list1_, list2_, fit_}, 
    opts : OptionsPattern[]] := 
Module[{plot1, plot2, ranges, p1, min, max}, 
    {plot1, plot2} = ListLinePlot /@ {list1, list2}; 
    ranges = [email protected]`[email protected]# & /@ {plot1, plot2}; 
    p1 = ListPlot[{list1, [email protected]{First /@ list2, 
     Rescale[Last /@ list2, [email protected], [email protected]]}}, 
    Frame -> True, FrameTicks -> {{Automatic, 
     Charting`FindTicks[[email protected], [email protected]]}, 
     {Automatic, Automatic}}, 
    FrameStyle -> {{Automatic, ColorData[97][2]}, 
     {Automatic, Automatic}}, FilterRules[{opts}, 
    Options[ListPlot]]]; 
    {min, max} = [email protected]`[email protected]; 
    Show[p1, Plot[fit, {x, min, max}]]] 

TwoAxisListPlot[{d1, d2, fit}, 
FrameLabel -> {{Row[{"Number of atoms, ", 
     Superscript[10, 3]}], "Temperature, \[Mu]K"}, 
    {"Time, s", ""}}, BaseStyle -> {FontSize -> 14}] 

enter image description here

+0

非常感謝Chris! –

+0

雖然它不適用於我的適合,它是NonLinearModelFit @ChrisDegnen –

+0

嘗試用'Plot [Normal,[bettafit],{tt,min,max]替換函數中的'Plot [fit,{x,min,max}]' }]'。 –

相關問題