2017-08-25 120 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}]' }]'。 –

相关问题