Hello all!
I am making a barchart but I have two problems.
1.
I have 8 values, each of them is between 0-100. Now if I get a smaller value (eg.: 68) the "x" line only reaches 80. How can I fix it to always show it until 100?
2.
How can I write the exact values at the end of each bars?
code:
Thank you for you help!
I am making a barchart but I have two problems.
1.
I have 8 values, each of them is between 0-100. Now if I get a smaller value (eg.: 68) the "x" line only reaches 80. How can I fix it to always show it until 100?
2.
How can I write the exact values at the end of each bars?
code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import numpy as np import matplotlib.pyplot as plt Enthusiastic = 10 Practical = 15 Immaginative = 20 Logical = 25 Auditive = 30 Visual = 80 Kinestetic_emotional = 40 Kinestetic_touching = 90 fig, ax = plt.subplots() plt.title ( "Personality test" ) plt.xlabel ( "Your score based on your answers" ) plt.ylabel ( "Types of thinking" ) thinking = ( "Enthusiastic" , "Practical" , "Immaginative" , "Logical" , "Auditive" , "Visual" , "Kinestetic(emotional)" , "Kinestetic(touching)" ) y_pos = np.arange( len (thinking)) scores = (Enthusiastic,Practical,Immaginative,Logical,Auditive,Visual,Kinestetic_emotional,Kinestetic_touching) ax.set_yticks(y_pos) ax.set_yticklabels(thinking,) ax.invert_yaxis() plt.barh(y_pos,scores,color = "g" ) plt.show() |
