islplot - Plotting of integer sets and relations

In [1]:
%pylab inline
# Load islpy and islplot
from islpy import *
from islplot.plotter import *
Populating the interactive namespace from numpy and matplotlib

The points of a set

In [2]:
plot_set_points(Set("{S[x,y]: 0 <= x <= 8 and -7 <= y <= 5}"),
                marker=".", color="gray", size=3)

plot_set_points(Set("{S[x,y]: 0 < x < 8 and 0 < y + x < 5}"),
                marker="o")

plot_set_points(Set("{S[x,y]: 4 < x < 8 and 0 < y < 5}"),
                marker="s", color="red")

plot_set_points(Set("{S[x,y]: 0 < x and y > -6 and y + x < 0}"),
                marker="D", color="blue")

Relations between points (maps)

In [3]:
plot_set_points(Set("{S[8,2]}"))
plot_set_points(Set("{S[2,8]}"))
plot_set_points(Set("{S[x,y]: 0 < x = y <= 9}"))
plot_map(Map("{S[2,8] -> [x,y]: 1 < x = y < 9}"))
plot_map(Map("{S[8,2] -> [x,y]: 1 < x = y < 9}"), edge_style="-", edge_width=3, color="orange")

The shape of a (basic) set

In [4]:
plot_set_points(Set("{S[x,y]: 0 < x, y < 10}"),
                marker=".", size=5, color="gray")
bs0 = BasicSet("{S[x,y]: 1 < x and 3y + x  < 20 and x - y < 2}")
plot_bset_shape(bs0, color="orange")
bs0 = BasicSet("{S[x,y]: 5 < x < 9 and 3 <= y <= 8 }")
plot_bset_shape(bs0, color="lightblue")
In [5]:
plot_set_points(Set("{S[x,y]: 0 < x, y < 10}"),
                marker=".", size=5, color="gray")
plot_set_shapes(Set("{S[x,y]: 1 <= x,y <= 3 or 5 <= x,y <= 7}"),
                color="orange")

The groups defined by a map

In [6]:
plot_set_points(Set("{S[x,y]: 0 <= x, y <= 10}"),
                marker=".", size=5)
plot_map_as_groups(Map("{[x,y] -> [floor(x/4), floor(y/6)]: 0 < x,y < 10}"),
                   color="orange")
In [7]:
plot_set_points(Set("{S[x,y]: 0 <= x, y <= 20}"),
                marker=".", size=5)
plot_map_as_groups(Map("{[x,y] -> [X,Y]: X = floor(x/4) and Y = floor(y/6) and 0 < x,y < 20 and (X + Y) % 2 = 0}"),
                   color="orange", vertex_size=6)
plot_map_as_groups(Map("{[x,y] -> [X,Y]: X = floor(x/4) and Y = floor(y/6) and 0 < x,y < 20 and (X + Y) % 2 = 1}"),
                   color="blue", vertex_size=6, vertex_marker="v")
In [8]:
domain = Set("{[i,j]: 0 <= i < 6 and 0 <= j < 6}")
dependences = Map("{[i,j]-> [i+1,j+1]; [i,j]-> [i+1,j]}")
tiling = Map("{[i,j] -> [floor(i/2), floor(j/2)]}")
space = Map("{[i,j] -> [i,i+j]}")
plot_domain(domain, dependences, tiling, space)