简体   繁体   中英

How to plot 2D array inside 3D array in python

Suppose you have a 3D array like this:

[[['1', '1'], ['1', '2'], ['1', '3']], 
 [['3', '1'], ['3', '2'], ['3', '3']], 
 [['2', '1'], ['2', '2'], ['2', '3'], ['2', '4'], ['2', '5']]]

Each 2D array is the x,y coordinates of a line. The 3D array is the compilation of lines in the data set. How can you plot each 2D array separately from the entire array? In other words, how can you plot a line with coordinates (1,1),(1,2),1,3) and another line (3,1),(3,2),(3,3), and so on?

import matplotlib.pyplot as plt
plt.plot([val1[0]  for val1 in lst_source[0] ], [val1[1]  for val1 in lst_source[0] ])
plt.plot([val1[0]  for val1 in lst_source[1] ], [val1[1]  for val1 in lst_source[1] ])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM