import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Voronoi, voronoi_plot_2d

import csv

COUNT_LIMIT = None
SAMPLE_LIMIT = 100

Points = []
with open('cell_info.csv', 'r', encoding='utf_8') as obj_file:
    csv_file = csv.reader(obj_file)
    for cnt, line in enumerate(csv_file):
        if COUNT_LIMIT and cnt >= COUNT_LIMIT:  # 只读取前 k 个点
            break
        Points.append([float(line[1]), float(line[2])])  # make up data points

# 随机抽取 n 个点
if SAMPLE_LIMIT:
    points = np.array([Points[i] for i in np.random.choice(len(Points), size = SAMPLE_LIMIT)])
else:
    points = np.array(Points)

# compute Voronoi tesselation
vor = Voronoi(points)

# plot
voronoi_plot_2d(vor)

# colorize
for region in vor.regions:
    if not -1 in region:
        polygon = [vor.vertices[i] for i in region]
        plt.fill(*zip(*polygon))

plt.show()
@@ -12,16 +12,34 @@
 y as np%0A
+import matplotlib%0A
 import m
@@ -112,16 +112,30 @@
 _plot_2d
+%0Aimport pandas
 %0A%0Aimport
@@ -135,19 +135,18 @@
 %0Aimport 
-csv
+os
 %0A%0ACOUNT_
@@ -177,330 +177,170 @@
 T = 
-100%0A%0APoints = %5B%5D%0Awith open('cell_info.csv', 'r', encoding='utf_8') as obj_file:%0A    csv_file = csv.reader(obj_file)%0A    for cnt, line in enumerate(csv_file):%0A        if COUNT_LIMIT and cnt %3E= COUNT_LIMIT:  # %E5%8F%AA%E8%AF%BB%E5%8F%96%E5%89%8D k %E4%B8%AA%E7%82%B9%0A            break%0A        Points.append(%5Bfloat(line%5B1%5D), float(line%5B2%5D)%5D)  # make up data points
+20%0A%0Acell_info = pandas.read_csv('cell_info.csv', header=None, dtype=%7B0: str, 1: float, 2:float%7D, nrows=COUNT_LIMIT)%0Acell_info.columns = (%22name%22, %22x%22, %22y%22)
 %0A%0A# %E9%9A%8F%E6%9C%BA%E6%8A%BD%E5%8F%96
  n %E4%B8%AA
@@ -339,13 +339,8 @@
 %E9%9A%8F%E6%9C%BA%E6%8A%BD%E5%8F%96
- n %E4%B8%AA%E7%82%B9
 %0Aif 
@@ -353,29 +353,28 @@
 _LIMIT:%0A    
-point
+cell
 s = np.array
@@ -379,17 +379,46 @@
 ay(%5B
-Points
+(cell_info%5B%22x%22%5D%5Bi%5D, cell_info%5B%22y%22%5D
 %5Bi%5D
+)
  for
@@ -444,22 +444,25 @@
 ice(len(
-Points
+cell_info
 ), size 
@@ -489,21 +489,20 @@
 se:%0A    
-point
+cell
 s = np.a
@@ -510,14 +510,27 @@
 ray(
-Points
+cell_info%5B%22x%22, %22y%22%5D
 )%0A%0A#
@@ -576,13 +576,12 @@
 noi(
-point
+cell
 s)%0A%0A
@@ -587,16 +587,22 @@
 %0A# plot%0A
+fig = 
 voronoi_
@@ -613,16 +613,124 @@
 _2d(vor)
+%0Afig.canvas.set_window_title(%22%E5%9F%BA%E7%AB%99%E6%9C%8D%E5%8A%A1%E8%8C%83%E5%9B%B4%E7%A4%BA%E6%84%8F%E5%9B%BE%22)%0Atitle = fig.suptitle(%22cell_info%22)%0Aax = fig.gca()%0Aax.set_aspect(1.)
 %0A%0A# colo
@@ -772,14 +772,14 @@
  if 
+-1 
 not
- -1
  in 
@@ -846,19 +846,22 @@
         
-plt
+_ = ax
 .fill(*z
@@ -873,16 +873,85 @@
 olygon))
+ # plt.fill((x0, x1, x2, x3, ...), (y0, y1, y2, y3, ...), color=None)
 %0A%0Aplt.sh

use pandas to load data and modified plot format