# Plotting Part of a wave in a particular way

So I have magnetic hystersis loop data that looks like the first attached picture. The X scale is a current that runs from the left to the right back to the left. However, it it is instead plotted against a "calculated" x wave, it looks like the second image. I seek to replicate the first image without having to load an x wave. I thought myself clever with a solution with this code.

function flipdat()

wave testwave1='wave1'
variable totpoints=numpnts(testwave1) //wave being inspected
make/o/n=(TOTPOINTS/2) testwave1a  //make 2 waves, each half the points of the source wave
make/o/n=(TOTPOINTS/2) testwave1b
wave testwave1a
wave testwave1b
Duplicate/o/r=(0,(totpoints/2)-1)testwave1, testwave1a //from 0-1/2 of the full points, make a new wave
Duplicate/o/r=(totpoints/2,totpoints-1) testwave1, testwave1b //from 1/2- full points , make the second wave
reverse/p testwave1b // reverse the second wave so that the second half  is upside down, like the first image
string graphname
prompt  Graphname," what is the Unique name of the graph?"
doprompt "Naming your graph" Graphname                               //give the graph a unique name
Display/k=1/N=\$graphname/W=(100,0,3000,1000) testwave1a   //make a graph with the first wave
appendtograph/w=\$graphname testwave1b   // append to the first waves' graph the second one

end

the propblem is that the graph ends up looking like my third picture. even though the data points for the duplicated "testwave1b" run from 0-40 on a table, they plot at 40-80 because that is what they were in the original wave. I think it has to do with some some dimensional stuff, since I ran into a similar problem with the reverse function, which was handily solved with the /p flag. I can see how it would be convenient to have a graph piece retain its absolute points in space in most cases, but in my case I need it to shift itself to start at 0, just like the other piece.
I'm sure there is something easy I'm msssing, but I hope ya'll can help, Thanks!
You can either use the SetScale operation on the second wave to change it's offset to -40 in the wave scaling itself, or you can use ModifyGraph offset={-40,0} to offset just the trace but not the wave itself. If that doesn't do what you need, you'll likely get better answers if you post an Igor experiment containing the data you want to plot.
Use the SetScale operation. Change the scaling on the second wave to start at 40 and increment with a negative step size. This will reset it to plot correctly as an overlay on a graph of the first wave.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH