using GMT
rect = [2 2; 2 6; 6 6; 6 2; 2 2];
plot(rect, region=[0 10 0 10], lw=1, fill=:blue, axes=:a, aspect=:equal, show=true)
Now add some patterns. The full pattern syntax is explained in [GMT patterns] (http://docs.generic-mapping-tools.org/latest/GMT_Docs.html#specifying-area-fill-attributes) but basically we are using pattern number 20 at 200 dpi and a blue background for the left rectangle and pattern 89 also at 200 dpis for the right rectangle.
This variation creates rectangles with 0, 30% and 70% transparency as well as different boundary lines.