简体   繁体   中英

Scatter plot in matplotlib origin aligned

I've looked all over the net for this incredibly simple thing and can't find it.

I have a list of (x,y) points and want to plot them, with the origin in the lower left, grid marks showing 0,1,2,3,4... on each axis, and orange dots. How do I do this?

Fairly basic, you should look a bit around in the matplotlib documentation, the examples or gallery section shows a lot of different stuff and the code that generated it.

import matplotlib.pyplot as plt
import numpy as np

#Random sample data
x = np.random.random_integers(0, 5, 10)
y = np.random.random_integers(0, 5, 10)

plt.scatter(x,y, c='orange')
plt.ylim([0, y.max()])
plt.xlim([0, x.max()])
plt.grid()
plt.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM