tAdded example of octahedron, added transparancy and line exception options - p… | |
git clone git://src.adamsgaard.dk/polygen | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit ba5bec68d87be35cff72f57af2ea41062f9760ef | |
parent 8e8c544294a8b2ec72f4b64641d51f85eb690168 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 13 Mar 2014 21:15:49 +0100 | |
Added example of octahedron, added transparancy and line exception options | |
Diffstat: | |
A octahedron.py | 10 ++++++++++ | |
M polygen.py | 11 +++++++---- | |
2 files changed, 17 insertions(+), 4 deletions(-) | |
--- | |
diff --git a/octahedron.py b/octahedron.py | |
t@@ -0,0 +1,10 @@ | |
+#!/usr/bin/env python | |
+ | |
+import numpy | |
+import polygen | |
+ | |
+octahedron = polygen.regular_star_polygon(8) | |
+#octahedron = polygen.regular_star_polygon(3) | |
+p = polygen.polyplot() | |
+p.set_points(octahedron.points) | |
+p.plot_all_to_all(line_width=4, exceptions=[[0,4], [1,5], [2,6], [3,7]]) | |
diff --git a/polygen.py b/polygen.py | |
t@@ -14,14 +14,16 @@ class polyplot: | |
def plot_all_to_all(self, line_color='k', line_width=2, | |
image_name='all_to_all', image_format='png', | |
- figure_size=(8,8), | |
+ figure_size=(8,8), transparent_background=True, | |
plot_points=False, points_style='wo', | |
- show_axes=False): | |
+ show_axes=False, exceptions=[]): | |
self.points = numpy.asarray(self.points) | |
fig = plt.figure(figsize=figure_size) | |
for i in range(self.points.shape[0]): | |
for j in range(self.points.shape[0]): | |
- if (i != j): | |
+ if (i != j and | |
+ ([i,j] in exceptions) == False and | |
+ ([j,i] in exceptions) == False): | |
plt.plot([self.points[i,0], self.points[j,0]], | |
[self.points[i,1], self.points[j,1]], | |
line_color + '-', lw=line_width) | |
t@@ -30,7 +32,8 @@ class polyplot: | |
plt.axis('equal') | |
if (show_axes == False): | |
plt.axis('off') | |
- fig.savefig(image_name + '.' + image_format) | |
+ fig.savefig(image_name + '.' + image_format, | |
+ transparent=transparent_background) | |
fig.clf() | |
class regular_star_polygon: |