I want make a graph of a part of the values of a dictionary.

I already stored the necessary values in a variable, but I just don't understand how to put them in a simple graph with just the numbers 1 to 500 on the x-axis and my values on the y-axis.

%matplotlib inline
import matplotlib.pyplot as plt

# Plot frequencies of the most 500 words
frequencies = freqs_sorted[len(freqs_sorted)-500:len(freqs_sorted)]

Everything I tried so far resulted in an empty graph. Thanks in advance!

1 Answers

Community On

From the matplotlib tutorial:

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
plt.plot(range(1, 501), frequencies)

P.S. In matplotlib you often have several ways to draw whatever you want. It is just one of them. Here is shorter version from @gboffi: