Is it possible to display each point's value next to it on chart diagram:
Values shown on points are: [7, 57, 121, 192, 123, 240, 546]
values = list(map(lambda x: x[0], result)) #[7, 57, 121, 192, 123, 240, 546]
labels = list(map(lambda x: x[1], result)) #['1950s', '1960s', '1970s', '1980s', '1990s', '2000s', '2010s']
plt.plot(labels, values, 'bo')
plt.show()
Here's my current code for this chart.
I would like to know each point value shown on graph, currently I can only predict values based on y-axis.
Based on your values, here is one solution using plt.text
fig = plt.figure()
ax = fig.add_subplot(111)
values = [7, 57, 121, 192, 123, 240, 546]
labels = ['1950s', '1960s', '1970s', '1980s', '1990s', '2000s', '2010s']
plt.plot(range(len(labels)), values, 'bo') # Plotting data
plt.xticks(range(len(labels)), labels) # Redefining x-axis labels
for i, v in enumerate(values):
ax.text(i, v+25, "%d" %v, ha="center")
plt.ylim(-10, 595)
Output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With