# Subtract two plots from one another

I have the graph below that is generated from a list of data ("data1"). If I have an equation that generates the second plot (see code below), which corresponds to the second peak of the first image, how can I subtract plot 1 from plot 2?.

    peak = amp2UserDefined*
Exp[-(x - x02UserDefined)^2/sigma2UserDefined^2]
peakplot = Plot[peak, {x, 60, 120}, PlotRange -> {-0.1, 0.1}]


Edit: The output of "peak" is 0.077 E^(-0.0349375 (-93.4 + x)^2) and data1 is can be found here https://pastebin.com/tn8PAPTB

• it will help to provide Data1 or code to generate it. Apr 22 '20 at 2:56
• Thank you Nasser. I have added data1 in the edits
– John
Apr 22 '20 at 3:04

Not very elegant:

data2 = Select[data1, 60 <= #[[1]] <= 120 &];
f[x_] := 0.077 E^(-0.0349375 (-93.4 + x)^2)
Union[Transpose[{data2[[;; , 1]],
data2[[;; , 2]] - f /@ data2[[;; , 1]]}], Complement[data1, data2]]//ListPlot


EDIT

f1[x_] := 0.07 E^(-0.170753 (-78.4 + x)^2)
Union[Transpose[{data2[[;; , 1]],
data2[[;; , 2]] - f /@ data2[[;; , 1]] - f1 /@ data2[[;; , 1]]}],
Complement[data1, data2]];


• Thank you Alx! This seems to work very well!. I am also open to other suggestions but this code does the job!
– John
Apr 22 '20 at 3:31
• Alx! One question, could you tell me how to modify your code in case I wanted to also subtract the first peak from the data1?. The output of the first peak is 0.07 E^(-0.170753 (-78.4 + x)^2). Thank you !
– John
Apr 22 '20 at 3:45
• First you need to know x coordinates of that range in data1, next is the same, it should be simply a replacement of {60, 120} range.
– Alx
Apr 22 '20 at 3:48
• Got it! But what I mean is how to subtract both at the same time from data1. They both have the same coordinates.
– John
Apr 22 '20 at 3:49
• I've edited my answer to subtract both peaks.
– Alx
Apr 22 '20 at 3:55