Skip to main content

plot_state_paulivec

Function plot_state_paulivec 

Source
pub fn plot_state_paulivec<S: StateVisualizationSource + ?Sized>(
    state: &S,
    options: &StatePlotOptions,
) -> Result<String, VisualizationError>
Expand description

Plot Pauli-basis expectation values as an SVG bar chart.

By default, labels follow crate::qis::pauli::PauliString: the rightmost character acts on qubit 0. For example, IX measures X on qubit 0 of a two-qubit state. Setting options.reverse_bits reverses the characters in each label without changing the state or the corresponding expectation value.

§Arguments

  • state - Input core state object accepted by state visualization routines.
  • options - Plot styling options such as title, colors, and bit order.

§Returns

SVG markup as a UTF-8 string.

§Errors

Returns VisualizationError::InvalidInput when the state payload is invalid.

§Examples

use cqlib_core::qis::Statevector;
use cqlib_core::visualization::{StatePlotOptions, plot_state_paulivec};
use num_complex::Complex64;

let state = Statevector::from_state(
    1,
    vec![Complex64::new(1.0, 0.0), Complex64::new(0.0, 0.0)],
).unwrap();
let svg = plot_state_paulivec(&state, &StatePlotOptions::default()).unwrap();
assert!(svg.contains("<svg"));