@@ -35,6 +35,11 @@ def interpolate_color(color1, color2, t):
3535def value_to_color (value , min_value , max_value ):
3636 """Map a value to a color based on a spectral colormap."""
3737
38+ if value < min_value :
39+ value = min_value
40+ elif value > max_value :
41+ value = max_value
42+
3843 # Define the spectral colormap (simplified)
3944 colormap = [
4045 Color .FromArgb (0 , 0 , 255 ), # Blue
@@ -110,7 +115,7 @@ def create_legend(min_value, max_value, steps=10, base_point=rg.Point3d(0, 0, 0)
110115 polyline = rg .Polyline (rect_pts )
111116
112117 legend_geometry .append (mesh )
113- # legend_geometry.append(polyline.ToPolylineCurve())
118+ legend_geometry .append (polyline .ToPolylineCurve ())
114119
115120 text_pt = rg .Point3d (x + 1.25 * width + spacing , y + i * (height + spacing ) + height / 10 , z )
116121 text_entity = rg .TextEntity ()
@@ -154,10 +159,13 @@ def create_histogram(values, min_value, max_value, steps=100, base_point=rg.Poin
154159
155160 # Count the frequencies of values in each bin
156161 for value in values :
157- if min_value <= value and value <= max_value :
158- bin_index = (value - min_value ) // bin_size
159- bin_index = int (bin_index )
160- frequencies [bin_index ] += 1
162+ if value < min_value :
163+ value = min_value
164+ elif value > max_value :
165+ value = max_value
166+ bin_index = (value - min_value ) // bin_size
167+ bin_index = int (bin_index )
168+ frequencies [bin_index ] += 1
161169
162170 x , y , z = base_point .X , base_point .Y , base_point .Z
163171
0 commit comments