Reputation: 21
I am stuck with the following problem: Using Matplotlib I need to plot an array of data, where the abscissa is a range of values (i.e. [1000..2000]), while the ordinate is represented by a single value.
I need to plot the data in a form of a bar, which starts at the value of 1000 (from the example above), and finishes at 2000. While in ordinate, the bar is located at the level of certain value defined above.
Any ideas ? I looked through various examples, but I only see bars and histograms which do something different.
Upvotes: 2
Views: 10721
Reputation: 5976
Just use plot
to make a wide line:
import matplotlib.pyplot as plt
plt.plot([1000, 2000], [5, 5], lw=10, color="orange", solid_capstyle="butt")#Setting capstyle to butt, because otherwise the length of the line is slightly longer, than required
plt.yticks(range(10))
plt.xticks(range(500, 3000, 500))
plt.margins(0.5)
plt.show()
Upvotes: 2