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/seaborn: first and last row cut in half of heatmap plot
- How to get different colored lines for different plots in a single figure?
- multiple axis in matplotlib with different scales [duplicate]
- How to maximize a plt.show() window using Python
- How to make two plots side-by-side using Python?
- Fill between two vertical lines in matplotlib [duplicate]
- How to plot multiple dataframes in subplots
- Matplotlib plot with variable line width
- Problem in combining bar plot and line plot (python)
- Bar Chart: How to choose color if value is positive vs value is negative
- How to plot data from multiple two column text files with legends in Matplotlib?
- cx_Freeze converted GUI-app (tkinter) crashes after pressing plot button
- How to change the text color of font in legend?
- Parallel Coordinates plot in Matplotlib
- Why set_xticks doesn’t set the labels of ticks?
- Using Matplotlib 3D axes, how to drag two axes at once
- Custom logarithmic axis scaling in matplotlib
- How to add group labels for bar charts
- How to update matplotlib’s imshow() window interactively?
- ValueError: view limit minimum -35738.3640567 is less than 1 and is an invalid Matplotlib date value
- Plotting time in with Matplotlib
- trouble aligning ticks for matplotlib twinx axes
- Getting vertical gridlines to appear in line plot in matplotlib
- Understanding matplotlib: plt, figure, ax(arr)?
- Matplotlib: Add colorbar to non-mappable object
- Using %matplotlib notebook after %matplotlib inline in Jupyter Notebook doesn’t work
- How to store an image in a variable
- Exact semantics of Matplotlib’s “interactive mode” (ion(), ioff())?
- Save plot to image file instead of displaying it
- How to find the intersection of two graphs