Dear Magasg,
a lot of people experience anxiety before and during doctor's visits. Often this results in high blood pressure, high hear rate, sweating, etc. There is even a name for it, namely the "white coat" effect.
I am not sure if anxiety has an effect on the ECG besides the high heart rate but probbly not.
Xanax may have an effect on the ECG.
In my opinion it is best to have the ECG without Xanax. Tell the nurse/examiner that you suffer from anxiety so they can take that into account.