I am trying to plot a continuous line from a series of coordinates but I would like to change the line color at specific junctures.
Input arrays:
layerdict['Xc'] = [50.6, 69.4, 69.4, 50.6, **50.6**, **50.2**, 69.8, 69.8, 50.2, **50.2**, **69.053**, 69.12, 69.12]
layerdict['Yc'] = [50.6, 50.6, 69.4, 69.4, **50.6**, **50.2**, 50.2, 69.8, 69.8, **50.2**, **50.88**, 50.996, 51.796]
** is just for visual purposes
I want to change the color of the line that goes from (50.6, 50.6) to (50.2,50.2) and (50.2, 50.6) to (69.053,5088) and so on... What is the best way to do this ? I have a conditional statement that can detect then conditions and insert blank values or other operations
Here is what I have so far.
layerdict = {'Xc': [], 'Yc': [], 'Xt': [], 'Yt': []}
with open(inputfilepath, 'r') as ifile:
for item in ifile:
gonematch = gonepattern.match(item)
gtrmatch = gtrpattern.match(item)
if gonematch:
tlist = item.split(' ')
layerdict['Xc'].append(float(tlist[1][1:]))
layerdict['Yc'].append(float(tlist[2][1:]))
elif gtrmatch:
tlist = item.split(' ')
layerdict['Xt'].append(float(tlist[1][1:]))
layerdict['Yt'].append(float(tlist[2][1:]))
plt.plot(layerdict['Xc'], layerdict['Yc'], label='linepath', linewidth=3.5)
plt.xlabel('X')
plt.ylabel('Y')
plt.show(block=True)
A sample Input file will look like this (just for reference, where I am extracting the coordinates from)
X10 Y10 A10 B10
X11 Y11 A10
X12.4 Y23.5 A5 ...