This commit is contained in:
admin 2026-01-29 13:52:31 -08:00
parent 0ca8f00d1b
commit 6b13480974

View File

@ -264,7 +264,7 @@ def get_image_grid_max(image_path, grid_size=(15,15)):
# 2. Create 3D Line Chart using Cairo (No Matplotlib) # 2. Create 3D Line Chart using Cairo (No Matplotlib)
def create_3d_line_chart_svg(data, output_path, svg_size=(1200, 1200)): def create_3d_line_chart_svg(data, output_path, svg_size=(800, 800)):
surface = cairo.SVGSurface(output_path, svg_size[0], svg_size[1]) surface = cairo.SVGSurface(output_path, svg_size[0], svg_size[1])
cr = cairo.Context(surface) cr = cairo.Context(surface)
@ -276,8 +276,8 @@ def create_3d_line_chart_svg(data, output_path, svg_size=(1200, 1200)):
# Projects (x,y,z) -> (x+z/2, y+z/2) # Projects (x,y,z) -> (x+z/2, y+z/2)
def project(x, y, z, xscale=20, yscale=10, offset=(0, 0)): def project(x, y, z, xscale=20, yscale=10, offset=(0, 0)):
shelf = 0 if z == 0 else z+2 shelf = 0 if z == 0 else z+2
#shelf = z shelf = z
return (offset[0] + x * xscale, offset[1] + y * yscale + shelf/2) return (offset[0] + x * xscale, offset[1] + y * yscale + shelf)
#return (offset[0] + x * scale + z * 2, offset[1] + y * scale + z * 2) #return (offset[0] + x * scale + z * 2, offset[1] + y * scale + z * 2)
rows, cols = data.shape rows, cols = data.shape
@ -289,8 +289,8 @@ def create_3d_line_chart_svg(data, output_path, svg_size=(1200, 1200)):
# Draw Lines along rows # Draw Lines along rows
cr.set_source_rgb(0, 0, 0) # Black lines cr.set_source_rgb(0, 0, 0) # Black lines
cr.set_line_width(1.0) cr.set_line_width(1.0)
lastz = 0 x=0
lasty = 0 y=0
for r in range(rows): for r in range(rows):
for c in range(cols): for c in range(cols):
z = norm_data[r, c] z = norm_data[r, c]
@ -299,14 +299,8 @@ def create_3d_line_chart_svg(data, output_path, svg_size=(1200, 1200)):
cr.move_to(x, y+50) cr.move_to(x, y+50)
cr.line_to(x, y) cr.line_to(x, y)
else: else:
if lastz == 0:
cr.line_to(x, lasty)
if z == 0 and lastz != 0:
cr.line_to(x, lasty)
cr.line_to(x, y) cr.line_to(x, y)
lastz=z cr.line_to(x, y + 50)
lasty=y
cr.move_to(x, y + 50)
cr.close_path() cr.close_path()
cr.set_source_rgb(1,1,1) cr.set_source_rgb(1,1,1)
cr.fill_preserve() cr.fill_preserve()
@ -339,6 +333,6 @@ logging.debug(t.end().report())
# Plot # Plot
t = Timerlog("Convert to SVG").start() t = Timerlog("Convert to SVG").start()
create_3d_line_chart_svg(grid_max, target_region_name+".svg", svg_size=(1200,1200)) create_3d_line_chart_svg(grid_max, target_region_name+".svg", svg_size=(800,800))
print("SVG file created: "+ target_region_name+".svg") print("SVG file created: "+ target_region_name+".svg")
logging.debug(t.end().report()) logging.debug(t.end().report())