fork download
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. # Data
  5. activities = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N']
  6. durations = [4, 10, 8, 7, 7, 5, 5, 9, 7, 13, 10, 2, 2, 1]
  7. predecessors = [[], ['A'], ['A'], ['B'], ['B', 'C'], ['C'], ['D'], ['D', 'E'], ['E'], ['E', 'F'], ['G', 'H', 'I'], ['H', 'I'], ['J', 'L'], ['M', 'K']]
  8.  
  9. # Create horizontal positions for activities
  10. x_pos = np.arange(len(activities))
  11.  
  12. # Bar chart
  13. plt.figure(figsize=(10, 6)) # Adjust the figure size as needed
  14.  
  15. # Plot bars
  16. bars = plt.bar(x_pos, durations, color='#007bff') # Customize the color if desired
  17.  
  18. # Plot predecessor connections
  19. for i, pred in enumerate(predecessors):
  20. for p in pred:
  21. plt.plot([x_pos[activities.index(p)], x_pos[i]], [durations[activities.index(p)], 0], 'k--')
  22.  
  23. # Axis labels and title
  24. plt.xlabel('Activity')
  25. plt.ylabel('Duration (days)')
  26. plt.title('Project Activities')
  27.  
  28. # Set x-axis tick labels
  29. plt.xticks(x_pos, activities)
  30.  
  31. plt.show()
  32.  
Success #stdin #stdout 2.25s 57060KB
stdin
Standard input is empty
stdout
Standard output is empty