Invert relationship between units and plotted data Matplotlib

I'm trying to get my plot with Matplotlib to plot as a function of time. My problem is I want the plot to display results from the end of the data (1.6 seconds to 0 seconds) but I want the units on the bottom to go from 0 seconds to 1.6 seconds. How do I change the relationship between the plotted data and the x-axis?

I can't show the plot since I need more reputation to post images.

Thanks for the help!


Instead of using plt.plot(x, y), reverse the x values and use plt.plot(x[::-1], y):

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 1.6, 100)
y = np.exp(-x*3)*x
fig, axs = plt.subplots(nrows=2, sharex=True)
axs[0].plot(x, y)
axs[1].plot(x[::-1], y)
plt.xlim(x.min(), x.max())

Here's an example using pyplot.

EDIT: To do what you want, you'll need to modify the plotting call:

Need Your Help

iOS Image View performance enhancement suggestions

iphone objective-c ios ipad

My app takes screenshots. I have a main screen with a scroll view that lets you cycle through those snapshots. The problem is, the more snapshots I have, the slower that view runs. I can get abou...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.