Python Forum
Matplotlib is all messed up!
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
Reply
#2
You made the same stupid mistake as me! Tongue
Why might the "numbers" on the y-axis not be in numerical order?... Think
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Text Order is Kinda Messed Up? Prithak 0 1,012 Feb-03-2022, 04:00 PM
Last Post: Prithak
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,161 Mar-11-2021, 10:52 AM
Last Post: buran
  python2 python3 messed up : How to fix ? hary 15 7,837 Dec-30-2020, 08:26 PM
Last Post: hary
  I think I messed up python.... XavPro_QC 7 13,877 Aug-02-2019, 09:02 PM
Last Post: XavPro_QC
  windows grep messed up Larz60+ 4 4,450 Mar-27-2017, 01:58 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020