Qx.Draw.VegaLite (Qx - Quantum Computing Simulator v0.5.0)

View Source

VegaLite visualization functions for quantum simulation results.

This module handles all VegaLite-based chart generation, including:

  • Probability distribution plots
  • Measurement count histograms
  • Raw probability histograms
  • Bloch sphere 2D projections

VegaLite visualizations are particularly useful in LiveBook environments where they provide interactive, publication-quality charts.

Internal Module

This module is part of the Qx.Draw refactoring and should be accessed through the public Qx.Draw API rather than directly.

Summary

Functions

Creates a VegaLite visualization of a qubit state on the Bloch sphere.

Creates a VegaLite histogram from raw probability data.

Creates a VegaLite plot of probability distribution from simulation result.

Creates a VegaLite plot of measurement counts from simulation result.

Functions

bloch_sphere(arg, title, size)

Creates a VegaLite visualization of a qubit state on the Bloch sphere.

Since VegaLite doesn't support native 3D rendering, this creates a 2D projection of the state vector onto the XZ plane.

Parameters

  • coords - Tuple of {x, y, z, theta, phi} Bloch sphere coordinates
  • title - Plot title
  • size - Size of the plot (width and height) in pixels

Returns

VegaLite specification showing the 2D projection of the Bloch sphere state.

Bloch Sphere Representation

  • |0⟩ state appears at the top (z = +1)
  • |1⟩ state appears at the bottom (z = -1)
  • |+⟩ state appears at the right (x = +1)
  • |-⟩ state appears at the left (x = -1)

histogram(data, title, width, height)

Creates a VegaLite histogram from raw probability data.

Parameters

  • data - List of maps with "state" and "probability" keys
  • title - Plot title
  • width - Plot width in pixels
  • height - Plot height in pixels

Returns

VegaLite specification for probability histogram.

plot(result, title, width, height)

Creates a VegaLite plot of probability distribution from simulation result.

Parameters

  • result - Simulation result map containing probabilities
  • title - Plot title
  • width - Plot width in pixels
  • height - Plot height in pixels

Returns

VegaLite specification that can be rendered in LiveBook or converted to other formats.

plot_counts(result, title, width, height)

Creates a VegaLite plot of measurement counts from simulation result.

Parameters

  • result - Simulation result containing measurement counts
  • title - Plot title
  • width - Plot width in pixels
  • height - Plot height in pixels

Returns

VegaLite specification showing count distribution of measurement outcomes.