It is easier to zip
, sort and unzip
the two lists of data.
Example:
xs = [...]
ys = [...]
xs, ys = zip(*sorted(zip(xs, ys)))
plot(xs, ys)
See the zip documentation here: https://docs.python.org/3.5/library/functions.html#zip
More Related Contents:
- Matplotlib scatterplot; color as a function of a third variable
- Matplotlib make tick labels font size smaller
- Moving matplotlib legend outside of the axis makes it cutoff by the figure box
- How to make a 4d plot with matplotlib using arbitrary data
- Matplotlib log scale tick label number formatting
- How do you set the absolute position of figure windows with matplotlib?
- Is it possible to get color gradients under curve in matplotlib?
- Matplotlib: Plotting numerous disconnected line segments with different colors
- Matplotlib: Finding out xlim and ylim after zoom
- How to overlay plots from different cells?
- List of all available matplotlib backends
- How to remove frame from matplotlib (pyplot.figure vs matplotlib.figure ) (frameon=False Problematic in matplotlib)
- How to hide in IPython notebook
- Matplotlib – Move X-Axis label downwards, but not X-Axis Ticks
- Scientific notation colorbar in matplotlib
- How to modify the navigation toolbar easily in a matplotlib figure window?
- Setting axes.linewidth without changing the rcParams global dict
- Matplotlib bar graph not drawing borders/edges
- How to remove or hide y-axis ticklabels from a matplotlib / seaborn plot
- Background with range on seaborn based on two columns
- matplotlib remove axis label offset by default
- Error in installing Matplotlib : fatal error C1083
- Python making combined bar and line plot with secondary y-axis
- Cancelling the offset on an axis [duplicate]
- How do you determine which backend is being used by matplotlib?
- Sorting the order of bars in pandas/matplotlib bar plots
- How to change matplotlib backends
- Date ticks and rotation [duplicate]
- Set markers for individual points on a line
- add colorbar to a sequence of line plots