# How to scale a part of a curve horizontally and vertically?

I have some data for curves, say $y(x,t)$, in which $x$ and $y$ cover different ranges. I need to compare them by shifting and stretching the curve horizontally and vertically.

This is the data for an example function.

The data can be imported by

Import["http://pastebin.com/raw/hrk0uMHb", "Table"]


I want to scale just the right part of the curve from the $y_{min}$ by the following functions:

$$Y(X)=\frac{y(x,t_0)}{0.01},\quad X=\frac{x-x_{min}}{0.001}$$

I use NMinimize to find the $y_{min}=0.440154692$ at $x_{min}=2.06704446$ on the curve $y(x,t_0)$. And the horizontal coordinate range $[x_{min},6.4]$ then need to be adjusted to cover a new range of $[0,6]$. After scaling, I want a curve like this. This is the data for the target curve. I want to show a best overlap between my rescaled curve and the target curve.

Thanks!

Thanks for @Jack LaVigne's scaledData, from its topological structure, I believe it is the first-scaled curve. Is there any method to rescale the scaledData to obtain a curve, which can show a good superposition on the target curve in a range of roughly {{0,4},{0.2,1.5}}?

• Solve for $Y(y)=100 y$ and $x(X)=0.001 X+x_{min}$ (yes, capitalization is correct) then plot $Y(y(x(X)),t_r)$ as a function of $X$. Interpolation is your friend here. – LLlAMnYP Jan 25 '16 at 16:37
• @ LLlAMnYP, Thanks, let me have a try. BTW, can you download the .dat file. It appears to be blocked on some browser... Just check with you. – W. Robin Jan 25 '16 at 16:41
• It downloaded fine, though dropbox is an unpleasant medium for this. With, say, pastebin I could simply run Import["http://pastebin.url.for.the.data", "Table"] and have it in MMA directly, here I needed to copy-paste. After your transformations the y range of your plot would be not .5 to 2, as you've shown, but rather 44.0156 to 44.0166. – LLlAMnYP Jan 25 '16 at 16:45
• There, I've stuck it into a pastebin for you (see edit). – LLlAMnYP Jan 25 '16 at 16:48
• @ LLlAMnYP, many thanks for your advice! – W. Robin Jan 25 '16 at 16:50

I won't repeat getting the data.

## Scale the data

First locate the position of the minimum

Position[data, Min[data[[All, 2]]]]
(* {{210, 2}} *)

xmin = data[[210, 1]]
(* 2.06705 *)

ymin = data[[210, 2]]
(* 0.440155 *)


Table is one way to scale the x and y data

scaledData = Table[{(point[[1]] - xmin)/0.001, point[[2]]/0.01},
{point, data[[210 ;; -1]]}]


It looks like this for everything to the right of xmin

ListLinePlot[scaledData]


In your example scaled plot the x-axis range is 0 to 6. Plotting the scaled data with this range produces a plot that doesn't match your scaled plot example.

ListLinePlot[scaledData, PlotRange -> {{0, 6}, {44.015, 44.017}}]


I am guessing that what you really wanted to do was to rescale y by subtracting ymin and using a much smaller divisor.

scaledData = Table[{(point[[1]] - xmin)/0.001, (point[[2]] - ymin)/0.00001},
{point, data[[210 ;; -1]]}]


If that is tried a plot that is closer to your example is the result

ListLinePlot[scaledData, PlotRange -> {{0, 6}, {0, 2}}]


## Create an interpolation function

One could make an interpolation function of the entire range of the scaled data or limit it to a range of interest.

f = Interpolation[scaledData[[1 ;; 10]]]


Now f can be used like any other pure function.

Plot[f[x], {x, 0, 6}, PlotRange -> {{0, 6}, {0, 2}}]


• Hi @ Jack LaVigne, thanks for your idea Table[{...},{...}], which is very useful!. I think with high confidence that the first plot is a similar figures, which should be what I need. But how can I rescale it to do a best overlap, especially the initial part roughly $[0, 4]$, with the target figure, as show in my post. Kindly access the target data from my updated post. Thanks! – W. Robin Jan 26 '16 at 16:03