I am trying to create a plot in matplotlib where the x-values are integers and the y-values are strings. Is it possible to plot data of this type in matplotlib? I examined the documentation and the gallery for matplotlib and could not find any examples of this type.
I have many lists bound to a variable called my_lists. The structure looks like this:
mylists = [765340, 765371, 765310,'MA011',],
[65310, 'MA015'],
[765422, 765422, 24920205, 24920161, 'MA125'],
[765422, 'MA105'],
[765371, 12345, 'MA004']
In each list, all items except the last item are x-values. The last item in each list is a string, which is the single y-value. How can I plot this is matplotlib? Here was my attempt:
import matplotlib.pyplot as plt
for sub_list in my_lists:
x_value = sub_list[:1]
y_value = sub_list[-1]
plt.plot(x_value, y_value, "ro")
plt.show()
The above code throws me this error:
ValueError: could not convert string to float: MA011
How can integers versus strings be plotted?