Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. y_values = [0.1, 0.3, 0.4, 0.2]
  4. text_values = ["word 1", "word 2", "word 3", "word 4"]
  5. x_values = np.arange(1, len(text_values) + 1, 1)
  6.  
  7. plt.bar(x_values, y_values, align='center')
  8. # Decide which ticks to replace.
  9. new_ticks = ["word for " + str(y) if y != 0 else str(y) for y in y_values]
  10. plt.yticks(y_values, new_ticks)
  11. plt.xticks(x_values, text_values)
  12. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement