How to generate a chart with distinct X and Y with the module matplotlib in Python?

-1

The goal would be to generate a bar chart where the Y axis runs from 0 to 10 (fixed mode), and the user would enter the maximum value of X (the X axis being 1 to the reported value).

    
asked by anonymous 09.07.2018 / 01:47

1 answer

0

I do not know if I understood your doubts correctly, but take a look at this solution that created the value of Y is fixed from 0 to 10 and that of X is variable according to what the user types.

Note: X values are stored in a list for easy reading.

import matplotlib.pyplot as plt

lista = []

for i in range(11):
    num = float(input('Digite a posição {}: '.format(i)))
    lista.append(num)

y = range(0,11)
x = lista
plt.ylabel(u'Eixo Y')
plt.xlabel(u'Eixo X')
plt.grid(True)
plt.bar(x, y)

plt.show()
    
10.07.2018 / 19:53