Working with Python! I am trying to use matplotlib on the jupyter notebook to graph a smooth curve scatter plot from data points in a dictionary like this, for example, and the positions of x and y are (x,y)
sampleData = {"sample 1": ('3','5'), "sample 2": ('2','1'), "sample 3": ('2','2'), "sample 4":('6','7')}
CODE:
import matplotlib.pyplot as plt sampleData = {"sample 1": ('3', '5'), "sample 2": ('2', '1'), "sample 3": ('2', '2'), "sample 4": ('6', '7')} x = [] y = [] # cleaning the dictionary to create 2 list of x and y co-ordinate for i in sampleData.items(): x.append(int(i[1][0])) y.append(int(i[1][1])) # plotting the list plt.scatter(x, y, c="blue") plt.show()
OUTPUT:
Please upvote if you like my answer and comment below if you have any queries or need any further explanation.
Get Answers For Free
Most questions answered within 1 hours.