I have a list of prices that I want to plot using matplotlib, and if I just do so, everything is fine. Here is my code:
def plot_prices_and_events(prices, buy=None, sell=None):
data = []
max_price = 0
min_price = sys.maxint
values = prices.get_values()
for price in values:
current_price = price[1]
data.append(current_price)
if current_price > max_price:
max_price = price[1]
if current_price < min_price:
min_price = current_price
plt.ylabel('Bitcoin price in EUR')
plt.xlabel('Date')
start_date = datetime.datetime.fromtimestamp(values[0][0])
end_date = datetime.datetime.fromtimestamp(values[-1][0])
plt.plot(data)
#plt.axis([start_date, end_date, min_price, max_price])
if buy is not None:
plt.plot(buy)
if sell is not None:
plt.plot(sell)
plt.show()
With the one line commented out, everything is fine:

Yet, if I try to set the scale for the x-axis, thus uncommenting the line, the axis are displayed correctly, but my plot disappears:
This is reproducible on two machines and by commenting and uncommenting the corresponding line. Am I missing something? I have already played around with the order of the commands, I checked the official tutorials and did some googling. The issue does not seem to be too far spread, so I hope for you people.
Thanks in advance and I hope I'm just stupid. ^^
EDIT: The issue is solved, but the solution is partly to be found in the comments. Bottom Line: The prices were not correctly ordered.

plt.plot()plots data as a function from[0:number_of_times]to prices. You have to specify the X-range correctly also in yourplt.plot()