Friday, February 10, 2023

The World of Screening Methods (P1)

screening-methods-p3

The World of Screening Methods (P1)

This post provides a plot of the “The world” of screening-like methods

import geopandas
import matplotlib.pyplot as plt

path_to_data = geopandas.datasets.get_path("nybb")
gdf = geopandas.read_file(path_to_data)

def plot_regions(coords, labels, fontsize):
    assert len(coords)==len(labels)
    n = len(labels)
    for i in range(n):
        alpha, beta = coords[i]
        x = x1 + alpha*(x2-x1) 
        y = y1+beta*(y2-y1)
        plt.text(x, y, s=labels[i], fontsize=fontsize)

plt.figure(figsize=(17, 9))
ax = gdf.plot(figsize=(16, 12), color=["gray", "blue", "blue", "green", "green"], alpha=0.5)
y1, y2 = ax.get_ylim()
x1, x2 = ax.get_xlim()
coords = [(0.6, 0.58), (0.5, 0.8), (0.15, 0.3), (0.1, 0.15)]
labels = ["Safe Screening", "Non-safe Sreening", "Squeezing", "Relaxing"]
plot_regions(coords, labels, fontsize=30) 
coords = [(0.6, 0.45), (0.5, 0.3), (0.8, 0.5), (0.8, 0.4), (0.75, 0.2)]
labels = ["Holder", "GAP", "EDPP", "FNE", "Region-free"]
plot_regions(coords, labels, fontsize=15)
plt.axis('off')
plt.show()

Popular Posts