from collections import Counter
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from scipy import linalg as la
defplot_histogram_file(filename, data, number_to_keep=False):
"""Plot a histogram of data.
data is a dictionary of {'000': 5, '010': 113, ...}
number_to_keep is the number of terms to plot and rest is made into a
single bar called other values
"""if number_to_keep isnotFalse:
data_temp = dict(Counter(data).most_common(number_to_keep))
data_temp["rest"] = sum(data.values()) - sum(data_temp.values())
data = data_temp
labels = sorted(data)
values = np.array([data[key] for key in labels], dtype=float)
pvalues = values / sum(values)
numelem = len(values)
ind = np.arange(numelem) # the x locations for the groups
width =0.35# the width of the bars
fig, ax = plt.subplots()
rects = ax.bar(ind, pvalues, width, color='seagreen')
# add some text for labels, title, and axes ticks
ax.set_ylabel('Probabilities', fontsize=12)
ax.set_xticks(ind)
ax.set_xticklabels(labels, fontsize=12, rotation=70)
ax.set_ylim([0., min([1.2, max([1.2* val for val in pvalues])])])
# attach some text labelsfor rect in rects:
height = rect.get_height()
ax.text(rect.get_x() + rect.get_width() /2., 1.05* height,
'%f'% float(height),
ha='center', va='bottom')
fig.savefig(filename)
You have access to great power!
['ibmqx2', 'ibmqx4', 'ibmqx5']
The least busy backend is ibmq_5_tenerife
Status @ 0 seconds
{'job_id': None, 'status': <JobStatus.INITIALIZING: 'job is being initialized'>,
'status_msg': 'Job is initializing. Please, wait a moment.'}{'job_id': '5b5428fe221a72003943d00f', 'status': <JobStatus.DONE: 'job has successfully run'>,
'status_msg': 'job has successfully run'}
You have made entanglement!