Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Matplotlib is all messed up!
#1
Hi! I created a convex hull algorithm in c and it outputs all the points and the convex hull into datapoints.txt and convexhull.txt.
However, when I use the code below matplotlib scrambles all the axis. Meaning that x-axis may be correct but the y one goes 5 20 10.

Is there any way to force matplotlib to simply draw a point on the coordinate that I read from a file?

main.py
import matplotlib.pyplot as plt

f = open("dataset.txt", "r")
data = f.read()
f.close()

data = data.split("\n")
data = data[:len(data)-1]
for datapoint in data:
    splitdata = list(datapoint.split(" "))
    plt.plot(splitdata[0], splitdata[1], "ro")

plt.show()
dataset.txt
10 10
15 5
16 10
16 20
30 10

Note: I remove the last element of data because Atom forces a newline on save...

Thanks! Smile
Quote
#2
You made the same stupid mistake as me! Tongue
Why might the "numbers" on the y-axis not be in numerical order?... Think
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Matplotlib : linewidth parameters Zopost 0 187 Aug-16-2019, 07:07 PM
Last Post: Zopost
  I think I messed up python.... XavPro_QC 7 223 Aug-02-2019, 09:02 PM
Last Post: XavPro_QC
  hatching not working properly with matplotlib Staph 3 107 Jul-28-2019, 07:17 AM
Last Post: ThomasL
  HX711&matplotlib problems olego 0 97 Jul-12-2019, 12:22 PM
Last Post: olego
  Matplotlib problem ift38375 0 114 Jul-02-2019, 02:55 PM
Last Post: ift38375
  Matplotlib contour no data coordinates b4rtt 1 224 Jun-18-2019, 09:36 AM
Last Post: b4rtt
  Matplotlib ImportError robertinoc 4 324 Jun-14-2019, 09:11 AM
Last Post: snippsat
  Matplotlib animation problem Potatoez 1 350 May-21-2019, 03:58 PM
Last Post: Potatoez
  MatplotLib Sliders punksnotdead 4 312 May-18-2019, 08:45 PM
Last Post: punksnotdead
  Animation using matplotlib query JohnDoe 0 164 May-09-2019, 08:07 PM
Last Post: JohnDoe

Forum Jump:


Users browsing this thread: 1 Guest(s)