Skip to main content

IQ Data and Constellation Diagrams

What are IQ data and constellation diagrams?​

IQ data is a radio signal recorded as pairs of samples: I (in-phase) and Q (quadrature, the same signal a quarter cycle later). Each pair is one complex number whose length is the signal's amplitude and whose angle is its phase. A constellation diagram plots those samples at each symbol instant as points on the I-Q plane, one cluster per symbol.

A simulated 16-QAM constellation diagram with 16 clusters of received symbols in a 4 by 4 grid on the I-Q plane, beside the I and Q signals plotted against time and the spectrum of the IQ samples

A simulated 16-QAM signal: the constellation (left), the I and Q signals against time (top right) and their spectrum (bottom right). Try the interactive version.

Key takeaways
  • IQ data stores a signal as complex samples, I + jQ: amplitude and phase in one number, independent of the carrier frequency.
  • A constellation diagram shows the received symbols as points. The number of clusters gives the modulation: 4 for QPSK, 16 for 16-QAM, 64 for 64-QAM.
  • The shape of the clusters points to the cause of a problem: round clouds for noise, arcs for phase noise, rings for a frequency offset, a squashed grid for IQ imbalance, pulled-in corners for compression.
  • Error vector magnitude (EVM) puts one number on the spread. With only noise present, EVM is about 1/SNR1/\sqrt{\text{SNR}}: 5.6% at 25 dB.
  • Plot I against Q with equal axis scales, or a squashed constellation can be an artefact of the chart.

What is IQ data? In-phase and quadrature samples​

IQ data describes a radio signal by two numbers per sample instead of one. Any signal near a carrier frequency fcf_c can be written as two waves 90° apart, each with its own slowly changing amplitude:

s(t)=I(t)cos⁡(2πfct)−Q(t)sin⁡(2πfct)s(t) = I(t)\cos(2\pi f_c t) - Q(t)\sin(2\pi f_c t)

I(t)I(t) and Q(t)Q(t) hold all the information the transmitter put on the carrier. Written as one complex number per sample, x=I+jQx = I + jQ:

  • the amplitude is I2+Q2\sqrt{I^2 + Q^2};
  • the phase is atan2⁡(Q,I)\operatorname{atan2}(Q, I);
  • a change of phase over time is a change of frequency.

How a receiver produces IQ data​

A receiver, a software-defined radio (SDR) or a vector signal analyser makes IQ data by quadrature downconversion. It multiplies the incoming signal by a local oscillator's cosine to get I and by its negative sine to get Q, low-pass filters both, and digitises them. The carrier is removed, so what's left is the complex baseband signal: the modulation alone, centred on 0 Hz.

A real-valued signal can do the same job only with twice the sample rate, because its spectrum is mirrored about 0 Hz and frequencies above and below the tuned centre land on top of each other. IQ samples keep them apart. A complex stream sampled at fsf_s covers a band fsf_s wide, from −fs/2-f_s/2 to +fs/2+f_s/2 around the tuned frequency; see Nyquist and aliasing for the sampling rules. The same pair, a signal plus a copy shifted by 90°, is what the Hilbert transform builds from a real signal: the analytic signal.

How IQ data is stored​

IQ recordings are usually interleaved pairs, I then Q, as 8-bit or 16-bit integers or 32-bit floats. The format and the sample rate aren't in the numbers themselves, so they travel as metadata: the open Signal Metadata Format (SigMF) stores them in a JSON file beside the samples, and ITU-R Recommendation SM.2117 defines a format for exchanging stored IQ data in spectrum monitoring.

How to plot IQ data: four views​

IQ data is plotted in four common ways, each answering a different question.

ViewAxesShowsUse it to
I and Q against timeTime, amplitudeTwo waveformsSee bursts, levels, clipping and timing
IQ plot (vector diagram)I, Q, every sampleThe path the signal traces between symbolsSee transitions and filtering
Constellation diagramI, Q, only at the symbol instantsOne cluster per symbolIdentify the modulation and judge quality
SpectrumFrequency, powerPower against frequency, both sides of 0 HzMeasure bandwidth, offsets and interference

The time view is the raw material. The IQ plot draws every sample, so a filtered signal shows curved paths between the symbol points. The constellation keeps only the samples at the moments the receiver decides which symbol was sent, so the paths disappear and each symbol becomes a dot.

The spectrum of IQ data is two-sided. A Fourier transform of complex samples gives different values at +f+f and −f-f, so the plot runs from −fs/2-f_s/2 to +fs/2+f_s/2 with the tuned frequency in the middle; see the fast Fourier transform guide. A spike exactly at 0 Hz usually comes from the receiver's own DC offset, not from the signal. For live spectra and waterfalls of IQ data, see the RF spectrum analyzer guide.

Constellation diagrams: BPSK, QPSK, 8PSK, 16-QAM and 64-QAM​

A constellation diagram for a digital modulation has one ideal point per symbol the transmitter can send. With MM points, each symbol carries log⁡2M\log_2 M bits.

ModulationPointsBits per symbolLayoutWhere it is used (examples)
BPSK (binary phase-shift keying)21Two points on a lineSatellite navigation signals, low-rate control links
QPSK (quadrature phase-shift keying)42Four points on a circle (the same as 4-QAM)Satellite TV, the most noise-tolerant mode of 4G and 5G
8PSK83Eight points on a circleSatellite broadcasting (DVB-S2)
16-QAM (quadrature amplitude modulation)1644 × 4 gridWi-Fi, 4G and 5G
64-QAM6468 × 8 gridWi-Fi, 4G and 5G, cable

PSK keeps every symbol at the same amplitude and uses only phase. QAM uses amplitude and phase, so its points fill a grid. Wi-Fi 6 (IEEE 802.11ax) goes up to 1024-QAM, 10 bits per symbol, for short, clean links.

More points carry more bits, but at the same average power they sit closer together. For square QAM the spacing between neighbours is d=6/(M−1)d = \sqrt{6/(M-1)} when the average symbol power is 1: 0.632 for 16-QAM and 0.309 for 64-QAM. Halving the spacing means the signal needs about 6 dB more SNR for the same error rate.

A 16-QAM constellation diagram drawn as a 4 by 4 grid of ideal points on the I and Q axes, each labelled with four Gray-coded bits, with dashed decision boundaries halfway between points, the spacing d between neighbours, and one received sample near the point 1011 joined to it by an error vector arrow

Gray coding: why neighbours differ by one bit​

Bits are assigned to the points with a Gray code, so any two neighbouring points differ in exactly one bit. Noise usually pushes a symbol only as far as a neighbour, so a symbol error then costs one wrong bit, not several. The diagram above uses one common convention: the first two bits pick the column (I) and the last two pick the row (Q). Standards define their own exact mappings, so check the one your system uses.

Decision boundaries​

The receiver decides which symbol was sent by picking the nearest ideal point. The dashed lines halfway between points are the decision boundaries. A sample that crosses one is decoded as the wrong symbol, which happens once noise or distortion moves it by more than d/2d/2 towards a neighbour.

How to read a constellation diagram, step by step​

Read a constellation from the whole pattern down to the single cluster:

  1. Check the chart. I and Q must have the same scale, or a perfect grid looks stretched. Check whether you are looking at symbol instants or every sample, and whether the receiver has already corrected the frequency and phase.
  2. Count the clusters. 2, 4, 8, 16 or 64 clusters identify the modulation and the bits per symbol. A ring or a blur instead of clusters means the receiver isn't locked yet.
  3. Is it centred? A pattern shifted off the origin means a DC offset in the receiver, usually with a spike at 0 Hz in the spectrum.
  4. Is it still? A pattern that spins, or smears into rings when many symbols are overlaid, means a frequency offset. A pattern that is still but rotated means a phase offset.
  5. Is it square? A grid stretched along I or Q means IQ gain imbalance. A square that leans into a rhombus means quadrature skew: I and Q aren't exactly 90° apart.
  6. What shape are the clusters? Round clouds of equal size mean noise. Arcs centred on the origin, longest on the outer points, mean phase noise. Small circles around every point mean an interfering tone. Outer points pulled towards the centre mean amplifier compression.
  7. How big are the clusters compared with the spacing? Clusters that reach the decision boundaries produce symbol errors.
  8. Read the numbers. EVM or MER puts a value on everything above; compare it with the limit for your modulation.

What impairments look like on a constellation diagram​

Each impairment distorts the constellation in its own way, so the shape often names the cause before any number does.

Eight small simulated 16-QAM constellation diagrams, one per impairment: noise gives round clouds of equal size, phase noise gives arcs that are longest at the edge, a frequency offset spins the pattern into rings, IQ gain imbalance stretches the grid along one axis, quadrature skew leans the square into a rhombus, compression pulls the outer points in, a DC offset shifts the whole pattern off centre and an interfering tone draws small circles around each point

ImpairmentWhat the constellation showsUsual causeAlso visible in
Noise (low SNR)Round, fuzzy clouds of the same size at every pointWeak signal, thermal noise in the receiverA raised noise floor in the spectrum
Phase noiseArcs centred on the origin; outer points spread furthestJitter in the local oscillatorsA skirt around the carrier in the spectrum
Frequency offsetThe pattern rotates; overlaid symbols form ringsTransmitter and receiver oscillators on slightly different frequencies, or Doppler shiftA spectrum shifted off centre
IQ gain imbalanceThe grid is stretched along one axis and squeezed along the otherI and Q paths with unequal gainA mirror image of the signal at the opposite frequency
Quadrature skewThe square grid leans into a rhombusThe two mixer signals not exactly 90° apartThe same mirror image
CompressionOuter and corner points pulled towards the centrePower amplifier driven close to saturationSpectral regrowth: shoulders either side of the channel
DC offsetThe whole pattern shifted off the originLocal oscillator leakage, DC offsets in the mixerA spike at 0 Hz
Interfering toneSmall circles around every pointA continuous-wave signal inside the channelA narrow spike inside the channel

Some rules of thumb, for small impairments on a constellation with an average power of 1:

  • Phase noise: an RMS phase error of σ\sigma radians adds about σ\sigma to the EVM. 3° is 0.052 rad, so about 5.2% EVM.
  • IQ imbalance: the mirror image sits 10log⁡10 ⁣[(1+2gcos⁡φ+g2)/(1−2gcos⁡φ+g2)]10 \log_{10}\!\big[(1 + 2g\cos\varphi + g^2)/(1 - 2g\cos\varphi + g^2)\big] dB below the signal, for an amplitude ratio gg between I and Q and a phase error φ\varphi. 1 dB of gain imbalance alone leaves the image only about 25 dB down; 2° of skew alone leaves it about 35 dB down.
  • Noise: EVM ≈ 1/SNR1/\sqrt{\text{SNR}} when noise is the only impairment, as worked through below.

EVM and MER: how to measure constellation quality​

Error vector magnitude (EVM) measures how far the received symbols sit from where they should be. For each symbol, the error vector runs from the ideal point to the received sample. EVM is the RMS length of the error vectors divided by the RMS length of the ideal symbols:

EVMrms=1N∑k∣rk−sk∣21N∑k∣sk∣2\text{EVM}_\text{rms} = \sqrt{\frac{\frac{1}{N}\sum_k |r_k - s_k|^2}{\frac{1}{N}\sum_k |s_k|^2}}

where rkr_k is the received symbol and sks_k the ideal one. It is given as a percentage, or in dB as 20log⁡10(EVM)20\log_{10}(\text{EVM}).

Modulation error ratio (MER) is the same comparison turned upside down and in decibels: the average ideal symbol power over the average error power. With this normalisation, MER in dB is minus the EVM in dB. Broadcasting and cable equipment tends to quote MER; cellular and Wi-Fi standards quote EVM.

Worked example: EVM from four QPSK symbols​

Take a QPSK constellation with ideal points at (±1,±1)(\pm 1, \pm 1), so each ideal symbol has power 12+12=21^2 + 1^2 = 2. Four symbols are received:

Ideal symbolReceivedError vectorError power ∣e∣2\lvert e \rvert^2
(1, 1)(1.10, 0.95)(0.10, −0.05)0.0125
(−1, 1)(−0.90, 1.05)(0.10, 0.05)0.0125
(−1, −1)(−1.05, −0.85)(−0.05, 0.15)0.0250
(1, −1)(0.95, −1.10)(−0.05, −0.10)0.0125
  • Mean error power: 0.0625/4=0.0156250.0625 / 4 = 0.015625.
  • Mean ideal power: 2.
  • EVM: 0.015625/2=0.0884\sqrt{0.015625 / 2} = 0.0884, or 8.8%, which is −21.1 dB.
  • MER: 10log⁡10(2/0.015625)=10log⁡10(128)=21.110 \log_{10}(2 / 0.015625) = 10 \log_{10}(128) = 21.1 dB.

In practice EVM is averaged over thousands of symbols, as in the demo below.

EVM and SNR​

When noise is the only impairment, and the receiver knows which symbols were sent, the error power is the noise power. Then EVM≈1/SNR\text{EVM} \approx 1/\sqrt{\text{SNR}} and MER equals the signal-to-noise ratio:

SNREVMMER
20 dB10.0%20 dB
25 dB5.6%25 dB
30 dB3.2%30 dB

Any other impairment adds to the EVM, so a measured EVM well above 1/SNR1/\sqrt{\text{SNR}} points to distortion rather than noise.

What is a good EVM?​

The limit depends on the modulation, because denser constellations have less room between points. For example, 3GPP TS 38.104 allows a 5G NR base station at most 17.5% RMS EVM for QPSK, 12.5% for 16-QAM, 8% for 64-QAM and 3.5% for 256-QAM. Standards also differ in how they normalise: most divide by the average symbol power, as above, but some divide by the power of the outermost symbol, which gives a smaller number for the same signal (by a factor of 1/1.81/\sqrt{1.8} for 16-QAM). State which one you use.

Constellation diagram vs eye diagram​

An eye diagram overlays many short slices of the I (or Q) signal against time, each one or two symbols long, so the traces form an "eye". The height of the opening shows the noise margin and its width shows the timing margin.

Constellation diagramEye diagram
AxesI against QAmplitude against time within a symbol
Best forPhase and amplitude errors, IQ imbalance, identifying the modulationTiming errors, jitter, intersymbol interference, choosing the sampling instant
HidesWhen in the symbol the sample was takenErrors in the other channel (Q or I)

They complement each other. A receiver sampling at the wrong moment shows a closed eye and a constellation with blurred, smeared clusters.

Where constellation diagrams are used​

Constellation diagrams are a standard view in vector signal analysers and SDR software. They are used in:

  • Wireless and wired communications: designing and testing Wi-Fi, 4G and 5G radios, cable modems and satellite links, where EVM limits are part of the standards.
  • Manufacturing test: checking every transmitter on a production line against its EVM limit.
  • Spectrum monitoring: regulators identify the modulation of signals they find in a band. In defence, signals intelligence uses the same displays; intercepting communications is regulated and carried out only by authorised agencies.
  • Optical fibre: coherent optical receivers recover IQ data from light and use the same constellations and EVM.

Common constellation diagram mistakes​

  • Unequal axis scales. A chart that autoscales I and Q separately turns a square grid into a rectangle, which looks exactly like IQ gain imbalance. Lock both axes to the same scale.
  • Reading the constellation before carrier recovery. A spinning pattern can be a receiver that hasn't locked yet, not a faulty transmitter. Check whether the frequency and phase have been corrected.
  • Plotting every sample instead of the symbol instants. The transitions between symbols fill the space between points and look like noise.
  • Comparing EVM figures with different normalisations. EVM relative to the peak symbol is lower than EVM relative to the average for the same signal, and some instruments report dB, others percent.
  • Too few symbols. A few hundred points can't show rare outliers or estimate EVM to better than a few tenths of a percent. Use thousands, with persistence so the density is visible.
  • Swapping I and Q or the sign of Q. The constellation is mirrored and the spectrum inverted. Check the convention of the recording.

How to plot IQ data and a constellation diagram in JavaScript, React or Angular​

SciChart.js draws scatter and line charts with WebGL, so a live constellation of tens of thousands of points stays smooth while new symbols arrive every frame. The demo simulates a signal from transmitter to receiver: random symbols, pulse shaping, amplifier compression, noise, phase noise, frequency offset and IQ imbalance, then a matched filter. Pick a Modulation, move the SNR, Phase noise, Frequency offset, IQ gain imbalance, Quadrature skew and Compression sliders and watch the constellation and the EVM readout change. Hover over the constellation to see the nearest ideal symbol and its bits, scroll to zoom, double-click to reset, and press Pause to freeze it.

Here is the code. The live demo includes the signal simulation; the React and Angular versions show the core pattern for your own IQ symbols:

// A live constellation diagram in JavaScript with SciChart.js: a simulated digitally modulated signal (BPSK to
// 64-QAM) passes through a model of a transmitter and receiver with adjustable impairments. The constellation keeps
// the last 30,000 symbols with fading persistence, next to the I and Q time traces and the spectrum.
// The signal processing below is plain JavaScript with no dependencies. All data is simulated.

const SAMPLES_PER_SYMBOL = 8; // the I and Q waveforms are sampled 8 times per symbol
const FILTER_SPAN = 8; // the pulse-shaping filter reaches 8 symbols either side of its centre
const ROLL_OFF = 0.35; // excess bandwidth of the root-raised-cosine filter (35%)
const SYMBOL_RATE = 1e6; // 1 million symbols per second (1 Mbaud), used to express the frequency offset in Hz
const PHASE_NOISE_SYMBOLS = 50; // how many symbols the phase noise stays roughly the same for

// Seeded random numbers, so the signal is the same every time the page loads
function makeRandom(seed) {
let state = seed;
const uniform = () => {
state = (state * 16807) % 2147483647;
return (state - 0.5) / 2147483647; // strictly between 0 and 1
};
// Box-Muller: two uniform numbers make one Gaussian number with mean 0 and standard deviation 1
const gaussian = () => Math.sqrt(-2 * Math.log(uniform())) * Math.cos(2 * Math.PI * uniform());
return { uniform, gaussian };
}

// The ideal symbol positions, scaled to an average power of 1, each with its Gray-coded bits.
// One common convention: the first half of the bits picks the column (I), the second half the row (Q).
function makeConstellation(name) {
const gray = (k, bits) => (k ^ (k >> 1)).toString(2).padStart(bits, "0");
const points = [];
if (name === "BPSK") {
points.push({ i: -1, q: 0, bits: "0" }, { i: 1, q: 0, bits: "1" });
} else if (name === "8PSK") {
for (let k = 0; k < 8; k++) points.push({ i: Math.cos((k * Math.PI) / 4), q: Math.sin((k * Math.PI) / 4), bits: gray(k, 3) });
} else {
// Square QAM: QPSK (4-QAM), 16-QAM and 64-QAM. Levels per axis are -L+1 ... L-1 in steps of 2
const levelsPerAxis = { QPSK: 2, "16QAM": 4, "64QAM": 8 }[name];
const bitsPerAxis = Math.log2(levelsPerAxis);
let power = 0;
for (let a = 0; a < levelsPerAxis; a++) {
for (let b = 0; b < levelsPerAxis; b++) {
const i = 2 * a - levelsPerAxis + 1;
const q = 2 * b - levelsPerAxis + 1;
points.push({ i, q, bits: gray(a, bitsPerAxis) + gray(b, bitsPerAxis) });
power += i * i + q * q;
}
}
const scale = 1 / Math.sqrt(power / points.length);
for (const p of points) {
p.i *= scale;
p.q *= scale;
}
}
return { name, points, bitsPerSymbol: Math.log2(points.length) };
}

// The index of the ideal point nearest to (i, q): what a receiver decides was sent
function nearestPoint(constellation, i, q) {
let best = 0;
let bestDistance = Infinity;
const points = constellation.points;
for (let k = 0; k < points.length; k++) {
const di = i - points[k].i;
const dq = q - points[k].q;
const d = di * di + dq * dq;
if (d < bestDistance) {
bestDistance = d;
best = k;
}
}
return best;
}

// Root-raised-cosine pulse, sampled SAMPLES_PER_SYMBOL times per symbol and scaled to unit energy.
// Filtering with it at the transmitter and again at the receiver gives a raised-cosine pulse: zero
// interference between symbols at the symbol instants.
function rootRaisedCosine() {
const half = FILTER_SPAN * SAMPLES_PER_SYMBOL;
const taps = new Float64Array(2 * half + 1);
const b = ROLL_OFF;
let energy = 0;
for (let n = -half; n <= half; n++) {
const t = n / SAMPLES_PER_SYMBOL; // time in symbols
let h;
if (n === 0) h = 1 - b + (4 * b) / Math.PI;
else if (Math.abs(Math.abs(t) - 1 / (4 * b)) < 1e-9)
h = (b / Math.SQRT2) * ((1 + 2 / Math.PI) * Math.sin(Math.PI / (4 * b)) + (1 - 2 / Math.PI) * Math.cos(Math.PI / (4 * b)));
else h = (Math.sin(Math.PI * t * (1 - b)) + 4 * b * t * Math.cos(Math.PI * t * (1 + b))) / (Math.PI * t * (1 - Math.pow(4 * b * t, 2)));
taps[n + half] = h;
energy += h * h;
}
for (let n = 0; n < taps.length; n++) taps[n] /= Math.sqrt(energy);
return taps;
}

// A streaming simulator of a received, digitally modulated signal:
// random symbols -> root-raised-cosine pulse shaping -> amplifier compression -> noise
// -> phase noise and frequency offset -> IQ gain imbalance and quadrature skew -> matched filter.
// next(count, settings) returns the next `count` received symbols (I, Q) and the symbols that were sent.
function createIqSimulator(seed) {
const random = makeRandom(seed);
const taps = rootRaisedCosine();
const half = FILTER_SPAN * SAMPLES_PER_SYMBOL;
const SYMBOL_RING = 8192; // ring buffers, sized as powers of 2 so an index wraps with a bit mask
const SAMPLE_RING = 65536;
const txI = new Float64Array(SYMBOL_RING);
const txQ = new Float64Array(SYMBOL_RING);
const txIndex = new Int32Array(SYMBOL_RING);
const rxI = new Float64Array(SAMPLE_RING);
const rxQ = new Float64Array(SAMPLE_RING);
let symbolsMade = 0; // symbols 0 ... symbolsMade - 1 exist
let samplesMade = 0; // received samples 0 ... samplesMade - 1 exist
let nextOut = FILTER_SPAN; // the next symbol to demodulate (skip the filter's start-up)
let phaseNoise = 0; // radians, a slowly wandering random phase
let carrierPhase = 0; // radians, grows steadily with a frequency offset
let constellation = makeConstellation("16QAM");

const makeSymbols = (upTo) => {
for (; symbolsMade <= upTo; symbolsMade++) {
const k = Math.min(constellation.points.length - 1, Math.floor(random.uniform() * constellation.points.length));
const slot = symbolsMade & (SYMBOL_RING - 1);
txI[slot] = constellation.points[k].i;
txQ[slot] = constellation.points[k].q;
txIndex[slot] = k;
}
};

// Make received samples up to (not including) sample `end`
const makeSamples = (end, s) => {
makeSymbols(Math.floor((end - 1 + half) / SAMPLES_PER_SYMBOL));
const noiseSd = Math.sqrt(1 / (2 * Math.pow(10, s.snrDb / 10))); // per I or Q: total noise power 1/SNR per sample
const txRms = Math.sqrt(1 / SAMPLES_PER_SYMBOL); // the shaped signal's RMS amplitude
const saturation = s.compression > 0 ? txRms * Math.pow(10, (12 - s.compression) / 20) : Infinity;
const pnDecay = Math.exp(-1 / (PHASE_NOISE_SYMBOLS * SAMPLES_PER_SYMBOL));
const pnStep = Math.sqrt(1 - pnDecay * pnDecay) * ((s.phaseNoiseDeg * Math.PI) / 180);
const phaseStep = (2 * Math.PI * s.frequencyOffsetHz) / (SYMBOL_RATE * SAMPLES_PER_SYMBOL);
const gainI = Math.pow(10, s.gainImbalanceDb / 40); // split the imbalance between I and Q
const gainQ = Math.pow(10, -s.gainImbalanceDb / 40);
const skew = ((s.quadratureSkewDeg / 2) * Math.PI) / 180; // split the skew between I and Q
const cosSkew = Math.cos(skew);
const sinSkew = Math.sin(skew);
for (let n = samplesMade; n < end; n++) {
// 1. Pulse shaping: each symbol is an impulse every SAMPLES_PER_SYMBOL samples, filtered by the RRC pulse
let i = 0;
let q = 0;
const first = Math.max(0, Math.ceil((n - half) / SAMPLES_PER_SYMBOL));
const last = Math.floor((n + half) / SAMPLES_PER_SYMBOL);
for (let k = first; k <= last; k++) {
const h = taps[n - k * SAMPLES_PER_SYMBOL + half];
const slot = k & (SYMBOL_RING - 1);
i += h * txI[slot];
q += h * txQ[slot];
}
// 2. Amplifier compression (Rapp model, smoothness 2): the amplitude is squeezed near saturation, the phase kept
if (saturation < Infinity) {
const r = Math.sqrt(i * i + q * q) / saturation;
const gain = 1 / Math.pow(1 + Math.pow(r, 4), 0.25);
i *= gain;
q *= gain;
}
// 3. White Gaussian noise
i += noiseSd * random.gaussian();
q += noiseSd * random.gaussian();
// 4. Phase noise (a random phase that wanders slowly) plus a frequency offset (a phase that grows steadily)
phaseNoise = pnDecay * phaseNoise + pnStep * random.gaussian();
// With no offset, the phase returns to 0: a receiver locked to the carrier
carrierPhase = phaseStep === 0 ? 0 : (carrierPhase + phaseStep) % (2 * Math.PI);
const c = Math.cos(phaseNoise + carrierPhase);
const sn = Math.sin(phaseNoise + carrierPhase);
const ri = i * c - q * sn;
const rq = i * sn + q * c;
// 5. IQ imbalance in the receiver's mixer: unequal I and Q gains, and I and Q not exactly 90 degrees apart
const slot = n & (SAMPLE_RING - 1);
rxI[slot] = gainI * (ri * cosSkew - rq * sinSkew);
rxQ[slot] = gainQ * (rq * cosSkew - ri * sinSkew);
}
samplesMade = end;
};

// The matched filter (the same RRC pulse) evaluated at sample n
const matchedFilter = (n) => {
let i = 0;
let q = 0;
for (let m = -half; m <= half; m++) {
if (n + m < 0) continue;
const slot = (n + m) & (SAMPLE_RING - 1);
i += taps[m + half] * rxI[slot];
q += taps[m + half] * rxQ[slot];
}
return [i, q];
};

const next = (count, settings) => {
const end = nextOut + count;
makeSamples((end - 1) * SAMPLES_PER_SYMBOL + half + 1, settings);
const out = {
i: new Float64Array(count),
q: new Float64Array(count),
refI: new Float64Array(count),
refQ: new Float64Array(count),
sent: new Int32Array(count)
};
for (let j = 0; j < count; j++) {
const k = nextOut + j;
const [i, q] = matchedFilter(k * SAMPLES_PER_SYMBOL);
const slot = k & (SYMBOL_RING - 1);
out.i[j] = i;
out.q[j] = q;
out.refI[j] = txI[slot];
out.refQ[j] = txQ[slot];
out.sent[j] = txIndex[slot];
}
nextOut = end;
return out;
};

// The last `symbols` symbols of the matched-filter output at every sample: the I and Q time traces
const recentWaveform = (symbols) => {
const start = (nextOut - symbols) * SAMPLES_PER_SYMBOL;
const length = (symbols - 1) * SAMPLES_PER_SYMBOL + 1;
const t = new Float64Array(length);
const i = new Float64Array(length);
const q = new Float64Array(length);
for (let j = 0; j < length; j++) {
const [a, b] = matchedFilter(start + j);
t[j] = j / SAMPLES_PER_SYMBOL;
i[j] = a;
q[j] = b;
}
return { t, i, q };
};

// The last `length` received samples before the matched filter, as a spectrum analyser would see them
const recentSamples = (length) => {
const i = new Float64Array(length);
const q = new Float64Array(length);
for (let j = 0; j < length; j++) {
const slot = (samplesMade - length + j) & (SAMPLE_RING - 1);
i[j] = rxI[slot];
q[j] = rxQ[slot];
}
return { i, q };
};

const setConstellation = (name) => {
constellation = makeConstellation(name);
// Restart cleanly so old and new symbols don't mix in the filters
symbolsMade = 0;
samplesMade = 0;
nextOut = FILTER_SPAN;
phaseNoise = 0;
carrierPhase = 0;
rxI.fill(0);
rxQ.fill(0);
};

return { next, recentWaveform, recentSamples, setConstellation, getConstellation: () => constellation };
}


// Iterative radix-2 FFT, in place, on complex samples (re, im). The length must be a power of 2.
function fft(re, im) {
const n = re.length;
for (let i = 1, j = 0; i < n; i++) {
let bit = n >> 1;
for (; j & bit; bit >>= 1) j ^= bit;
j ^= bit;
if (i < j) {
[re[i], re[j]] = [re[j], re[i]];
[im[i], im[j]] = [im[j], im[i]];
}
}
for (let size = 2; size <= n; size *= 2) {
const halfSize = size / 2;
const step = (-2 * Math.PI) / size;
for (let start = 0; start < n; start += size) {
for (let k = 0; k < halfSize; k++) {
const wr = Math.cos(step * k);
const wi = Math.sin(step * k);
const a = start + k;
const b = a + halfSize;
const tr = re[b] * wr - im[b] * wi;
const ti = re[b] * wi + im[b] * wr;
re[b] = re[a] - tr;
im[b] = im[a] - ti;
re[a] += tr;
im[a] += ti;
}
}
}
}

// Power spectral density of complex IQ samples with a Hann window, centred on 0 Hz, in dB.
// Scaled so white noise of power P per sample reads 10 log10(P): with this demo's signal, the flat top of the
// spectrum sits near 0 dB and the noise floor near -SNR dB.
function iqSpectrumDb(i, q) {
const n = i.length;
const re = new Float64Array(n);
const im = new Float64Array(n);
let windowPower = 0;
for (let j = 0; j < n; j++) {
const w = 0.5 - 0.5 * Math.cos((2 * Math.PI * j) / n);
re[j] = i[j] * w;
im[j] = q[j] * w;
windowPower += w * w;
}
fft(re, im);
const psd = new Float64Array(n);
for (let k = 0; k < n; k++) {
const shifted = (k + n / 2) % n; // negative frequencies first, so 0 Hz is in the middle
psd[k] = (re[shifted] * re[shifted] + im[shifted] * im[shifted]) / windowPower;
}
return psd;
}

async function createIqCharts(constellationDiv, tracesDiv, spectrumDiv) {
const {
SciChartSurface,
NumericAxis,
NumberRange,
EAutoRange,
XyDataSeries,
XyScatterRenderableSeries,
FastLineRenderableSeries,
EllipsePointMarker,
LegendModifier,
CursorModifier,
MouseWheelZoomModifier,
ZoomPanModifier,
ZoomExtentsModifier,
DpiHelper,
SciChartJsNavyTheme
} = SciChart;
// or, for npm, import { SciChartSurface, ... } from "scichart"

const BATCH = 500; // symbols added per animation frame, in one appendRange call per series
const PERSISTENCE = 30000; // the constellation keeps the last 30,000 symbols
const TRACE_SYMBOLS = 24; // the I and Q time traces show the last 24 symbols
const SPECTRUM_SAMPLES = 2048; // samples per spectrum (256 symbols)
const AXIS_LIMIT = 1.9; // the constellation's I and Q range: -1.9 to +1.9
const titleStyle = { fontSize: 15, color: "#C8D3E6" };
const axisTitleStyle = { fontSize: 14 };

// --- Chart 1: the constellation. Three scatter layers with FIFO buffers make a fading persistence display:
// every symbol goes into all three, so the newest symbols are drawn three times (brightest) and the oldest once.
const constellation = await SciChartSurface.create(constellationDiv, {
theme: new SciChartJsNavyTheme(),
title: "Constellation (simulated signal)",
titleStyle
});
const cs = constellation.sciChartSurface;
const cw = constellation.wasmContext;
const iAxis = new NumericAxis(cw, { axisTitleStyle, axisTitle: "I (in-phase)", autoRange: EAutoRange.Never, labelPrecision: 1 });
const qAxis = new NumericAxis(cw, { axisTitleStyle, axisTitle: "Q (quadrature)", autoRange: EAutoRange.Never, labelPrecision: 1 });
iAxis.visibleRange = new NumberRange(-AXIS_LIMIT, AXIS_LIMIT);
qAxis.visibleRange = new NumberRange(-AXIS_LIMIT, AXIS_LIMIT);
cs.xAxes.add(iAxis);
cs.yAxes.add(qAxis);
const layers = [
{ capacity: PERSISTENCE, color: "#50C7E038" },
{ capacity: PERSISTENCE / 5, color: "#50C7E088" },
{ capacity: 3 * BATCH, color: "#C9F1FA" }
].map(({ capacity, color }) => {
const dataSeries = new XyDataSeries(cw, { fifoCapacity: capacity, containsNaN: false });
cs.renderableSeries.add(
new XyScatterRenderableSeries(cw, {
dataSeries,
pointMarker: new EllipsePointMarker(cw, { width: 3, height: 3, fill: color, stroke: color, strokeThickness: 0 })
})
);
return dataSeries;
});
// Faint rings at the ideal symbol positions, and an orange ring on the symbol under the mouse
const idealSeries = new XyDataSeries(cw, { containsNaN: false });
const hoverSeries = new XyDataSeries(cw, { containsNaN: false });
cs.renderableSeries.add(
new XyScatterRenderableSeries(cw, {
dataSeries: idealSeries,
pointMarker: new EllipsePointMarker(cw, { width: 13, height: 13, fill: "#00000000", stroke: "#FFFFFFAA", strokeThickness: 1.5 })
}),
new XyScatterRenderableSeries(cw, {
dataSeries: hoverSeries,
pointMarker: new EllipsePointMarker(cw, { width: 24, height: 24, fill: "#00000000", stroke: "#F48420", strokeThickness: 2.5 })
})
);
cs.chartModifiers.add(new MouseWheelZoomModifier(), new ZoomPanModifier());

// --- Chart 2: I and Q against time, after the receiver's matched filter, with dots at the symbol instants ---
const traces = await SciChartSurface.create(tracesDiv, {
theme: new SciChartJsNavyTheme(),
title: `I and Q against time (last ${TRACE_SYMBOLS} symbols)`,
titleStyle
});
const ts = traces.sciChartSurface;
const tw = traces.wasmContext;
ts.xAxes.add(new NumericAxis(tw, { axisTitleStyle, axisTitle: "Time (symbols)", autoRange: EAutoRange.Never, visibleRange: new NumberRange(0, TRACE_SYMBOLS - 1) }));
ts.yAxes.add(new NumericAxis(tw, { axisTitleStyle, axisTitle: "Amplitude", autoRange: EAutoRange.Never, visibleRange: new NumberRange(-1.9, 1.9), labelPrecision: 1 }));
const iTrace = new XyDataSeries(tw, { dataSeriesName: "I", dataIsSortedInX: true, containsNaN: false });
const qTrace = new XyDataSeries(tw, { dataSeriesName: "Q", dataIsSortedInX: true, containsNaN: false });
const iInstants = new XyDataSeries(tw, { dataSeriesName: "I at symbol instants", dataIsSortedInX: true, containsNaN: false });
const qInstants = new XyDataSeries(tw, { dataSeriesName: "Q at symbol instants", dataIsSortedInX: true, containsNaN: false });
const instantMarkers = [
new XyScatterRenderableSeries(tw, {
dataSeries: iInstants,
pointMarker: new EllipsePointMarker(tw, { width: 7, height: 7, fill: "#50C7E0", stroke: "#FFFFFF", strokeThickness: 1 })
}),
new XyScatterRenderableSeries(tw, {
dataSeries: qInstants,
pointMarker: new EllipsePointMarker(tw, { width: 7, height: 7, fill: "#F48420", stroke: "#FFFFFF", strokeThickness: 1 })
})
];
ts.renderableSeries.add(
new FastLineRenderableSeries(tw, { dataSeries: iTrace, stroke: "#50C7E0", strokeThickness: 2 }),
new FastLineRenderableSeries(tw, { dataSeries: qTrace, stroke: "#F48420", strokeThickness: 2 }),
...instantMarkers
);
const traceLegend = new LegendModifier({ showCheckboxes: true });
const traceCursor = new CursorModifier({ showTooltip: true, showAxisLabels: false });
ts.chartModifiers.add(traceLegend, traceCursor, new MouseWheelZoomModifier(), new ZoomPanModifier(), new ZoomExtentsModifier());
for (const markers of instantMarkers) {
traceLegend.includeSeries(markers, false); // the legend and tooltip list only the I and Q lines
traceCursor.includeSeries(markers, false);
}

// --- Chart 3: the spectrum of the received IQ samples, from -4 to +4 times the symbol rate ---
const spectrum = await SciChartSurface.create(spectrumDiv, {
theme: new SciChartJsNavyTheme(),
title: "Spectrum of the IQ samples",
titleStyle
});
const ss = spectrum.sciChartSurface;
const sw = spectrum.wasmContext;
ss.xAxes.add(new NumericAxis(sw, { axisTitleStyle, axisTitle: "Frequency (× symbol rate)", autoRange: EAutoRange.Never, visibleRange: new NumberRange(-4, 4), labelPrecision: 0 }));
ss.yAxes.add(new NumericAxis(sw, { axisTitleStyle, axisTitle: "Power (dB)", autoRange: EAutoRange.Never, visibleRange: new NumberRange(-55, 10), labelPrecision: 0 }));
const spectrumSeries = new XyDataSeries(sw, { dataSeriesName: "Power spectral density", dataIsSortedInX: true, containsNaN: false });
ss.renderableSeries.add(new FastLineRenderableSeries(sw, { dataSeries: spectrumSeries, stroke: "#68BCAE", strokeThickness: 1.5 }));
ss.chartModifiers.add(
new CursorModifier({ showTooltip: true, showAxisLabels: false }),
new MouseWheelZoomModifier(),
new ZoomPanModifier(),
new ZoomExtentsModifier()
);
const frequencies = Array.from({ length: SPECTRUM_SAMPLES }, (_, k) => ((k - SPECTRUM_SAMPLES / 2) / SPECTRUM_SAMPLES) * SAMPLES_PER_SYMBOL);

// --- The simulation, and an animation loop that feeds it to the charts ---
const simulator = createIqSimulator(7);
let settings = null;
let running = true;
let frame = 0;
let averagedPsd = null;
const errorWindow = []; // per-batch sums for EVM and symbol errors over the persistence window

const setModulation = (name) => {
simulator.setConstellation(name);
const points = simulator.getConstellation().points;
idealSeries.clear();
idealSeries.appendRange(points.map((p) => p.i), points.map((p) => p.q));
hoverSeries.clear();
for (const layer of layers) layer.clear();
errorWindow.length = 0;
averagedPsd = null;
};

// EVM: the RMS length of the error vectors (received minus sent), relative to the RMS of the ideal symbols
const measure = () => {
let errorPower = 0;
let referencePower = 0;
let symbolErrors = 0;
let count = 0;
for (const b of errorWindow) {
errorPower += b.errorPower;
referencePower += b.referencePower;
symbolErrors += b.symbolErrors;
count += b.count;
}
const evm = Math.sqrt(errorPower / Math.max(referencePower, 1e-12));
return { evm, merDb: -20 * Math.log10(Math.max(evm, 1e-6)), symbolErrors, count };
};

// Keep the constellation square, so a squashed or skewed grid is really squashed or skewed on screen
const keepSquare = () => {
const rect = cs.seriesViewRect;
if (!rect || rect.width < 10 || rect.height < 10) return;
const q = qAxis.visibleRange;
const centre = (iAxis.visibleRange.min + iAxis.visibleRange.max) / 2;
const halfWidth = ((q.max - q.min) / 2) * (rect.width / rect.height);
const current = (iAxis.visibleRange.max - iAxis.visibleRange.min) / 2;
if (Math.abs(current - halfWidth) > 0.002 * halfWidth) iAxis.visibleRange = new NumberRange(centre - halfWidth, centre + halfWidth);
};

const updateTracesAndSpectrum = () => {
const wave = simulator.recentWaveform(TRACE_SYMBOLS);
iTrace.clear();
iTrace.appendRange(wave.t, wave.i);
qTrace.clear();
qTrace.appendRange(wave.t, wave.q);
const instants = [];
const iAtInstants = [];
const qAtInstants = [];
for (let j = 0; j < wave.t.length; j += SAMPLES_PER_SYMBOL) {
instants.push(wave.t[j]);
iAtInstants.push(wave.i[j]);
qAtInstants.push(wave.q[j]);
}
iInstants.clear();
iInstants.appendRange(instants, iAtInstants);
qInstants.clear();
qInstants.appendRange(instants, qAtInstants);

const samples = simulator.recentSamples(SPECTRUM_SAMPLES);
const psd = iqSpectrumDb(samples.i, samples.q);
if (!averagedPsd) averagedPsd = psd;
else for (let k = 0; k < psd.length; k++) averagedPsd[k] = 0.8 * averagedPsd[k] + 0.2 * psd[k]; // smooth the noise
const powerDb = new Float64Array(psd.length);
for (let k = 0; k < psd.length; k++) powerDb[k] = 10 * Math.log10(Math.max(averagedPsd[k], 1e-12));
spectrumSeries.clear();
spectrumSeries.appendRange(frequencies, powerDb);
};

let onMeasured = (measurement) => {};
const animate = () => {
if (cs.isDeleted) return; // stop when the chart is deleted
if (running && settings) {
const batch = simulator.next(BATCH, settings);
// One appendRange per layer per frame; the FIFO buffers drop the oldest symbols by themselves
for (const layer of layers) layer.appendRange(batch.i, batch.q);
const constellationNow = simulator.getConstellation();
let errorPower = 0;
let referencePower = 0;
let symbolErrors = 0;
for (let j = 0; j < BATCH; j++) {
const di = batch.i[j] - batch.refI[j];
const dq = batch.q[j] - batch.refQ[j];
errorPower += di * di + dq * dq;
referencePower += batch.refI[j] * batch.refI[j] + batch.refQ[j] * batch.refQ[j];
if (nearestPoint(constellationNow, batch.i[j], batch.q[j]) !== batch.sent[j]) symbolErrors++;
}
errorWindow.push({ errorPower, referencePower, symbolErrors, count: BATCH });
if (errorWindow.length > PERSISTENCE / BATCH) errorWindow.shift();
// The traces, spectrum and readout change every 6th frame: often enough to look live, slow enough to read
if (frame % 6 === 0) {
updateTracesAndSpectrum();
onMeasured(measure());
}
frame++;
}
keepSquare();
requestAnimationFrame(animate);
};

// Hover: find the ideal symbol nearest the mouse, ring it, and report its bits
let onHover = (hovered) => {};
constellationDiv.addEventListener("mousemove", (event) => {
const rect = constellationDiv.getBoundingClientRect();
const view = cs.seriesViewRect; // in canvas pixels, which are CSS pixels × DpiHelper.PIXEL_RATIO
const x = (event.clientX - rect.left) * DpiHelper.PIXEL_RATIO - view.left;
const y = (event.clientY - rect.top) * DpiHelper.PIXEL_RATIO - view.top;
if (x < 0 || y < 0 || x > view.width || y > view.height) {
hoverSeries.clear();
onHover(null);
return;
}
const i = iAxis.getCurrentCoordinateCalculator().getDataValue(x);
const q = qAxis.getCurrentCoordinateCalculator().getDataValue(y);
const c = simulator.getConstellation();
const point = c.points[nearestPoint(c, i, q)];
hoverSeries.clear();
hoverSeries.append(point.i, point.q);
onHover({ point, i, q, bitsPerSymbol: c.bitsPerSymbol });
});
constellationDiv.addEventListener("mouseleave", () => {
hoverSeries.clear();
onHover(null);
});
// Double-click resets the zoom
constellationDiv.addEventListener("dblclick", () => {
qAxis.visibleRange = new NumberRange(-AXIS_LIMIT, AXIS_LIMIT);
iAxis.visibleRange = new NumberRange(-AXIS_LIMIT, AXIS_LIMIT);
});

requestAnimationFrame(animate);
return {
setModulation,
setSettings: (s) => {
settings = s;
errorWindow.length = 0; // measure the EVM afresh for the new settings
},
setRunning: (r) => (running = r),
onMeasured: (callback) => (onMeasured = callback),
onHover: (callback) => (onHover = callback)
};
}

Key points:

  • Fading persistence: the constellation is three XyScatterRenderableSeries layers that receive the same symbols, with fifoCapacity of 1,500, 6,000 and 30,000 and increasing transparency. The newest symbols are drawn three times, so they are brightest; the oldest fade into the background, and the FIFO buffers discard them without any extra code.
  • Batches: each animation frame appends 500 symbols to each layer with a single appendRange call of typed arrays (Float64Array), never point by point.
  • Square axes: both axes use EAutoRange.Never, and the demo resets the I range to match the chart's width-to-height ratio, so IQ imbalance and skew are shown at their true shape.
  • The I and Q traces are FastLineRenderableSeries with scatter markers at the symbol instants; the spectrum is a Hann-windowed FFT of the complex samples, written in plain JavaScript. Swap the simulator for your SDR's IQ stream to plot real data.

See it in the demo app: JavaScript scatter chart · React scatter chart · Angular scatter chart. For a persistence display on line traces, see the JavaScript real-time ghosted traces chart · React real-time ghosted traces chart · Angular real-time ghosted traces chart.

Go deeper: SciChart.js scatter chart documentation, real-time updates and FIFO data series, and the related guides: signal-to-noise ratio, Hilbert transform and fast Fourier transform.

Frequently asked questions​

What is IQ data?​

IQ data is a radio signal recorded as pairs of numbers: I, the in-phase part, and Q, the quadrature part, which is the same signal measured a quarter of a cycle later. Each pair is one complex sample, I + jQ, whose length is the signal's amplitude and whose angle is its phase. Software-defined radios, spectrum analysers and digital receivers all produce IQ data.

Why do radios use I and Q instead of a single signal?​

One real-valued sample cannot tell a frequency above the tuned centre from one below it, and cannot separate amplitude from phase. Two samples taken 90 degrees apart can. With I and Q, a receiver sampling at rate fs captures a band fs wide centred on the tuning frequency, measures amplitude and phase directly, and can demodulate any modulation in software.

How do you read a constellation diagram?​

Check that the I and Q axes have the same scale, count the clusters to find the modulation and bits per symbol, then check that the pattern is centred, still and square. Next look at the shape of each cluster: round clouds mean noise, arcs mean phase noise, rings mean a frequency offset and pulled-in corners mean compression. Finally compare the cluster size with the spacing between points and read the EVM.

What is the difference between QPSK and QAM?​

QPSK puts four points on a circle, so every symbol has the same amplitude and carries 2 bits in its phase. QAM changes both amplitude and phase, so its points form a grid: 16-QAM has 16 points and 4 bits per symbol, 64-QAM has 64 points and 6 bits. QPSK is the same constellation as 4-QAM. Larger QAM grids carry more bits but put the points closer together, so they need a cleaner signal.

What is a good EVM?​

It depends on the modulation: the more points, the lower the EVM must be. The 5G NR base station standard, 3GPP TS 38.104, allows up to 17.5% RMS EVM for QPSK, 12.5% for 16-QAM, 8% for 64-QAM and 3.5% for 256-QAM. When noise is the only impairment, EVM is about 1 divided by the square root of the SNR, so 5.6% corresponds to an SNR of 25 dB.

How do I plot a constellation diagram in JavaScript?​

Put the I values on the x axis and the Q values on the y axis of a scatter chart, with both axes on the same scale. In SciChart.js, use an XyScatterRenderableSeries with an XyDataSeries, and set fifoCapacity on the data series so it keeps only the newest symbols. Append each block of received symbols with one appendRange call, which keeps tens of thousands of points smooth in real time.

Sources​