Skip to content

Commit a86c71c

Browse files
committed
WIP-ADD histogram
1 parent b97817a commit a86c71c

File tree

2 files changed

+456
-1294
lines changed

2 files changed

+456
-1294
lines changed

src/gh/diffCheck/diffCheck/df_vizualization.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ def create_legend(min_value, max_value, steps=10, base_point=rg.Point3d(0, 0, 0)
106106
mesh.VertexColors.Add(previous_color.R, previous_color.G, previous_color.B)
107107
mesh.VertexColors.Add(color.R, color.G, color.B)
108108
mesh.VertexColors.Add(color.R, color.G, color.B)
109-
mesh.VertexColors.Add(color.R, color.G, color.B)
110-
111109

112110
polyline = rg.Polyline(rect_pts)
113111

@@ -133,7 +131,7 @@ def create_legend(min_value, max_value, steps=10, base_point=rg.Point3d(0, 0, 0)
133131
return legend_geometry
134132

135133

136-
def create_histogram(values, min_value, max_value, steps=10, base_point=rg.Point3d(0,0,0), height=0.1, spacing=0.1):
134+
def create_histogram(values, min_value, max_value, steps=100, base_point=rg.Point3d(0, 0, 0), height=0.1, spacing=0):
137135
"""
138136
Create a histogram in Rhino with a polyline representing value frequencies.
139137
@@ -159,21 +157,20 @@ def create_histogram(values, min_value, max_value, steps=10, base_point=rg.Point
159157
if min_value <= value and value <= max_value:
160158
bin_index = (value - min_value) // bin_size
161159
bin_index = int(bin_index)
162-
if bin_index == steps:
163-
bin_index -= 1
164160
frequencies[bin_index] += 1
165161

166162
x, y, z = base_point.X, base_point.Y, base_point.Z
167163

168164
# Create points for the polyline representing the histogram
169-
points = [rg.Point3d(x, y, z)]
170-
for i in range(int(steps)):
171-
172-
bar_height = frequencies[i] * height
173-
points.append(rg.Point3d(x + bar_height, y + i * (spacing + height), z))
174-
points.append(rg.Point3d(x, y + (i + 1) * (spacing + height), z))
165+
points = []
166+
for i in range(steps+1):
167+
168+
bar_height = frequencies[i] * 0.01 * height
169+
print(bar_height)
170+
points.append(rg.Point3d(x - bar_height - 0.15 , y + i * (spacing + height), z))
171+
175172
# Create the polyline and add it to the histogram geometry
176-
polyline = rg.Polyline(points)
177-
histogram_geometry.append(points)
173+
polyline = rg.Curve.CreateInterpolatedCurve(points, 1)
174+
histogram_geometry.append(polyline)
178175

179176
return histogram_geometry

0 commit comments

Comments
 (0)