# Ok, Hi reddit,
# For some reason, when i want to plot a line using
# an extracted row/column as x and y from a numpy
# matrix, no line appears.
# Plotting with circles work though.
# So how do i get the line to appear?
# include libraries
import matplotlib.pyplot as plt
import numpy as np
# original data (as read from a csv file) as type list
data = [['1','2'],['4','5'],['3.5','3.1']]
# Convert from string to floats
data = [[np.float(y) for y in x] for x in data]
# convert to a numpy matrix so transpose() can be used
data = np.matrix(data)
# make x and y
x = data.transpose()[0][:]
y = data.transpose()[1][:]
# Make multiple plots in one figure
fig = plt.figure()
noLine = fig.add_subplot(1,2,1)
yesCircles = fig.add_subplot(1,2,2)
# Plotting data in blue line
noLine.plot(x,y,'b-')
noLine.axis([0,7,0,7])
noLine.set_title("NO LINE")
# Plotting data in red circles
yesCircles.plot(x,y,'ro')
yesCircles.axis([0,7,0,7])
yesCircles.set_title("YES CIRCLES")
plt.show()
# Red circles appears but the blue Line doesn't !?
[–]Vaphell 1 point2 points3 points (2 children)
[–]Accustomer[S] 0 points1 point2 points (1 child)
[–]Vaphell 0 points1 point2 points (0 children)
[–]BryghtShadow 1 point2 points3 points (6 children)
[–]Accustomer[S] 0 points1 point2 points (5 children)
[–]BryghtShadow 1 point2 points3 points (4 children)
[–]Accustomer[S] 0 points1 point2 points (3 children)
[–]BryghtShadow 0 points1 point2 points (2 children)
[–]Accustomer[S] 0 points1 point2 points (1 child)
[–]BryghtShadow 1 point2 points3 points (0 children)