I have made a bar graph that works and includes all data. However, the graph starts at the lowest integer the user has input instead of 0.
Here is my code:
import matplotlib.pyplot as plt
definition = input('Definition of data set: ')
x = input('X-axis label: ')
datax = input('Enter X-axis data (Term): ').split()
y = input('Y-axis label: ')
datay = input('Enter Y-axis data (Integer): ').split()
plt.bar(datax, height=datay, width=0.6, color=['red','black'], )
plt.xlabel(x)
plt.ylabel(y)
plt.title(definition);
plt.title(definition)
plt.show()
Here is the output:
Definition of data set: Amount of ants on different types of food
X-axis label: Types of food
Enter X-axis data (Term): pineapple apple chocolate
Y-axis label: Amount of ants
Enter Y-axis data (Integer): 1 2 7
As you can see, pineapple has the lowest number of ants (1) so there is no bar. I want the y-axis to start on 0.
