iplot_histogram
iplot_histogram(data, figsize=None, number_to_keep=None, sort='asc', legend=None)
Create a histogram representation.
Graphical representation of the input array using a vertical bars style graph.
Parameters
- data (list or dict) – This is either a list of dicts or a single dict containing the values to represent (ex. {‘001’ : 130})
- figsize (tuple) – Figure size in pixels.
- number_to_keep (int) – The number of terms to plot and rest is made into a single bar called other values
- sort (string) – Could be ‘asc’ or ‘desc’
- legend (list) – A list of strings to use for labels of the data. The number of entries must match the length of data.
Raises
VisualizationError – When legend is provided and the length doesn’t match the input data.
Example
from qiskit import QuantumCircuit, BasicAer, execute
from qiskit.visualization import iplot_histogram
%matplotlib inline
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])
backend = BasicAer.get_backend('qasm_simulator')
job = execute(qc, backend)
iplot_histogram(job.result().get_counts())
Was this page helpful?
Report a bug or request content on GitHub.