1

In this chart how do I multiply all labels in the X-axis by a constant?

It still needs to be automatic, only scaled by a 0.4 factor

0 → 140 would become 0 → 56 in this example.

enter image description here

My current code:

ind = np.arange(baby.shape[0])
width = 1
p1 = plt.bar(ind, baby, width)
p2 = plt.bar(ind, adult, width, bottom=baby)
p3 = plt.bar(ind, rain, width, bottom=adult+baby)
p4 = plt.bar(ind, snoring, width, bottom=rain+adult+baby)
p5 = plt.bar(ind, street, width, bottom=snoring+rain+adult+baby)
plt.legend((p1[0], p2[0], p3[0], p4[0], p5[0]), ('Bebê', 'Adulto', 'Chuva', 'Ronco', 'Externo'))
plt.show(block=False)
0

1 Answer 1

2

Usually you would not fake the labels, but rather plot the data you want to show. In this case

width = 1*0.4
plt.bar(ind*0.4, baby, width)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.