Well X an Y are all zero, so I can only think you want to plot z against D!
Probably, you can get the numpy array coords below directly using numpy, but I never use numpy, so I don't know how to do that. Also I hardly ever use mathplotlib, so I am no expert.
Try out the following in your Python shell, step for step:
import csv
import glob
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)
path = '/home/pedro/myPython/csv/csv/'
csvs = glob.glob(path + '*.csv')
for file in csvs:
print('The csv files are', file)
myfile = input('Copy and paste the file you want here ... ')
# csv_reader is gone after you use it one time
# it is convenient to copy the data to a list
with open(myfile) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
data = []
for row in csv_reader:
data.append(row)
Zs = []
Ds = []
for d in range(1, len(data)):
print(data[d][2], data[d][3])
Zs.append(int(data[d][2]))
Ds.append(float(data[d][3]))
# show the data in the lists
for i in range(len(Zs)):
print(Zs[i], Ds[i])
minimumZ = min(Zs)
maximumZ = max(Zs)
minimumD = min(Ds)
maximumD = max(Ds)
print('The minimum and maximum Z are', minimumZ, maximumZ)
print('The minimum and maximum D are', minimumD, maximumD)
# no difference if you use () or [] so only use 1 of these
coords = np.array([Zs, Ds])
coords = np.array((Zs, Ds))
for c in coords:
print(c)
def tp1():
plt.rcParams["figure.figsize"] = [10, 10]
maximumD = max(Ds)
x, y = coords
fig, ax = plt.subplots(num="Showing y = D ") # Create a figure and an axes.
ax.plot(x, y, label='y = D') # Plot some data on the axes.
ax.set_xlabel('x values') # Add an x-label to the axes.
ax.set_ylabel('y values') # Add a y-label to the axes.
ax.set_title("As z gets bigger, D gets bigger") # Add a title to the axes.
plt.axhline(y = maximumD, color = 'r', linestyle = 'dashed', label='y = D')
ax.legend() # Add a legend.
fig.text(.4, .25, "The ups and downs", va="center", ha="center",
bbox=dict(boxstyle="round, pad=1", facecolor="w"))
plt.show()
# now just run the function tp1()
tp1()
mathplotlib can do many things as decoration. Look up the docs!