From: Robin Krens Date: Sat, 27 Jan 2024 14:26:58 +0000 (+0100) Subject: haptic-extractor.py: two subplots X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=81b4fb3abf2de6f4a256b8c99bbf3d33b78f9904;p=haptic-extractor haptic-extractor.py: two subplots --- diff --git a/haptic-extractor.py b/haptic-extractor.py index 9119a93..a45ea36 100644 --- a/haptic-extractor.py +++ b/haptic-extractor.py @@ -125,16 +125,25 @@ print(f"\nBit Depth: {bit_depth} bits") 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]) @@ -144,11 +153,11 @@ ax.set_yticklabels([]) #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')