Hey IBM quantum noobie here, Everytime I run my circuits, I get the results graph’s measurement basis (x axis) in hexadecimal form, how do i change this so that the results graph in in the computation basis. (for example the hexadecimal 0xF would turn into the binary number 1111)


1 Answer 1


Usually, when you run an experiment on IBM quantum backend, both job.result().get_counts() and job.result().get_memory() return binary-encoded numbers. If, however, you got hexadecimal numbers you can use Counts class to convert them as follows:

from qiskit.result import Counts

raw_data = {"0x0": 39, "0x2": 204, "0x3": 617, "0x2E": 3140}
_counts = Counts(raw_data, memory_slots=6)

The result should be:

{'000000': 39, '000010': 204, '000011': 617, '101110': 3140}

Another option is to use ProbDistribution class, which can be used as follows:

from qiskit.result import ProbDistribution

dist = ProbDistribution(raw_data)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.