# How to make an vivid artificial peak in a specified place?

I have a such graphics which plot by this data,and its range of x is from 10 to 90 commonly:

data = (Uncompress@*FromCharacterCode@*
Flatten@*(ImageData[#1, "Byte"] &)@*Import)[
"http://ooo.0o0.ooo/2016/12/14/5850ba5019da8.png"];


I want make an artificial peak in some specified place,such as the red arrow point. I can made it by Photoshop,but little troublesome: But can I do it in Mathematica?

## Current try

range = Select[data, 42 < First[#] < 49 &];
gapData = Complement[data, range];
xpos = Round[Length[range]/2];
range[[xpos - 10 ;; xpos + 10]] = {range[[xpos, 1]], 2000};
range = Transpose[{First /@ range, MeanFilter[Last /@ range, 3]}];
smoothData = SortBy[Join[gapData, range], First];
ListLinePlot[smoothData, PlotRange -> All] If I use MeanFilter,I will get a little fat peak sometimes,but actually it cannot be that.

If a simple ReplacePart is not sufficient here, you can define a function that uses a window to add a peak around a neighbourhood. Here is an example of what I mean:

ClearAll[addPeak]
addPeak[position_Integer, {size_, width_Integer}][data : {{_, _} ..}] /;
((position > width) && (position < (Length@data - width))) :=
ReplacePart[data,
Table[q -> {data[[q, 1]],
data[[q, 2]] + size BartlettWindow[(q - position)/width]}, {q,
position - width, position + width}]];
addPeak[position_Integer, {size_, width_Integer}][data : {{_, _} ..}] :=
data;


You can change BartlettWindow to any preset windowing function (or pass it on as an option).

Here's the result of adding a peak of magnitude 1000 at position 2025 of width 840 data points:

ListLinePlot[addPeak[2025, {1000, 420}][data], PlotRange -> All] and here is the result of adding a narrower peak of width 100 points and magnitude 4000 to the same point:

ListLinePlot[addPeak[2025, {4000, 50}][data], PlotRange -> All] Even if it's not precisely what you are looking for, it should get you started.

• Maybe we should rescale that 2025 to {10,90}. :) – yode Dec 14 '16 at 5:04
• I don't quite understand? 2025 refers to the position of the centre of the peak – gpap Dec 14 '16 at 5:06
• Yep,I got that.I mean,it is not easy to know that position is 2025.:) – yode Dec 14 '16 at 5:07
• Ah, I see now. Well, all you need is to call it like (if, say you want the peak at 45.): addPeak[Sequence @@ First@Position[data, {45., _}], {4000, 50}][data] – gpap Dec 14 '16 at 5:11