gsize_w = 100
-fig, ax = plt.subplots(figsize=(4, 2.25)) # Adjust the figure size as needed
+#fig, ax = plt.subplots(figsize=(4, 2.25)) # Adjust the figure size as needed
+fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(3, 3), gridspec_kw={'height_ratios': [3, 1]})
# Plot the grayscale line plot
-ax.plot(image_flat, linestyle='-', linewidth=2, color='gray')
+ax1.plot(image_flat, linestyle='-', linewidth=2, color='gray')
# Customize x and y ticks
-ax.set_xticks([0, 25, 50])
-ax.set_yticks([])
-ax.set_xticklabels([])
-ax.set_yticklabels([])
+ax1.set_xticks([])
+ax1.set_ylim(0, 255) # Set y-axis range from 0 to 255
+ax1.set_yticks([0, 128, 255]) # Adjust y-axis ticks as needed
+ax1.set_xticklabels([])
+ax1.set_yticklabels([])
+
+# Plot the image on the second subplot (ax2)
+ax2.imshow(image, cmap="gray")
+ax2.axis('off') # Hide axis for the image subplot
+
+plt.subplots_adjust(hspace=0)
+fig.tight_layout(rect=[0, 0, 1, 0.95])
# Add the original image at the bottom
#axins = ax.inset_axes([0, -0.3, 1, 0.3])
#axins.set_xticks([])
#axins.set_yticks([])
-fig.subplots_adjust(bottom=0, top=1, hspace=0)
+#fig.subplots_adjust(bottom=0, top=1, hspace=0)
-bottom_image_ax = fig.add_axes([0.05, 0.0, 1, 0.01])
-bottom_image_ax.imshow(image, cmap='gray')
-bottom_image_ax.axis('off')
+#bottom_image_ax = fig.add_axes([0.05, 0.0, 1, 0.01])
+#bottom_image_ax.imshow(image, cmap='gray')
+#bottom_image_ax.axis('off')
plt.savefig('output_plot.png', dpi=300, bbox_inches='tight')