Ask here about the “What Did You Expect?” Codebook topic from the “Single-Qubit Gates” module.
1 Like
Hello again! I am here to ask for the plotter function implementation
Hi @lawun330 ,
Here’s what we use for plotting!
import altair as alt
import pandas as pd
def plotter(shot_vals, results_experiment, results_scaling):
"""Plot the value of the output
Args:
shot_vals (np.array[int]): Angles for the x axis.
results_experiment (np.array[float]): Variances from the experiments
results_scaling (np.array[float]): Variances computed from scaling function.
"""
df = pd.DataFrame(
{
"shots": shot_vals,
"experiment": results_experiment,
"function": results_scaling,
}
)
plot = (
alt.Chart(df)
.transform_fold(["experiment", "function"], ["var_type", "variance"])
.mark_point()
.encode(x="shots:Q", y="variance:Q", color="var_type:N")
)
return plot
1 Like