0
import shapefile as shp
import matplotlib.pyplot as pltsf = shp.Reader("D:/New folder1/21_8_2016.shp")

plt.figure()
for shape in sf.shapeRecords():
    x = [i[0] for i in shape.shape.points[:]]
    y = [i[1] for i in shape.shape.points[:]]
    plt.plot(x, y)
plt.show()

this shows my hsapefile in alot colours how do i assign it a single colour ?

1 Answer 1

4

The plot function has colour options. You can simply add the arguments, as follows:

import shapefile as shp
import matplotlib.pyplot as pltsf = shp.Reader("D:/New folder1/21_8_2016.shp")

plt.figure()
for shape in sf.shapeRecords():
    x = [i[0] for i in shape.shape.points[:]]
    y = [i[1] for i in shape.shape.points[:]]
    plt.plot(x, y, color = 'red')
plt.show()

Check this link for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.