How can I plot an array into a 2-d plot where y-axis is number of occurence of data in array in python? -
so have array of numbers, , want plot how many times each number occurs in array. x-axis should numbers in array, , y-axis should number of times each number occurs in array. there way program in python? have trouble when try import numpy or matplotlib.pyplot, there way can this?
t = [1, 2, 3, 1, 2, 5, 6, 7, 8] #your original list of numbers noduplicates = list(set(t)) #gets rid of duplicates in list listoftuples = [] number in noduplicates: count = t.count(number) newtuple = [number, count] listoftuples.append(newtuple) this creates list of tuples fist number of tuple number trying count , second number count. work decimals first solution did not because did not know needed work decimals. list of tuples should able create graph.
Comments
Post a Comment