Save image in original resolution
See original GitHub issueHi! I want to save my plot with the ScaleBar, here is my code:
fig, ax = plt.subplots()
ax.axis("off")
ax.imshow(my_slice3, cmap="gray")
scalebar = ScaleBar(650, "nm", length_fraction=0.25, location= "lower right")
ax.add_artist(scalebar)
plt.savefig('foo.png')
When I save the image, the resolution is not anymore the resolution of the original image.
At Stack Overflow I found the hint, that one can use imsave , but that is not working with the Scalebar.
https://stackoverflow.com/questions/31544130/saving-an-imshow-like-image-while-preserving-resolution
I know that I can increase the resolution e.g. with
plt.rcParams['figure.dpi'] = 300 .
But that is not leading to the exact pixel-by-pixel image.
Any idea how to solve this?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
"Save as Picture" saves images in low resolution
When using the right-click option Save as Picture to save an image from a Word document, the image is saved in very low...
Read more >How do I save the image in the original resolution? - MathWorks
1. Download the "export_fig" function from the File Exchange. Here is the link: · 2. Extract the compressed folder and add it to...
Read more >How to Save Internet Pictures in High Resolution - Techwalla
Open the picture in photo-editing software, and look at the image size. You will see the pixel dimensions listed (such as 800 by...
Read more >How to download original image resolution - Super User
Right-click on the image, and select Save Image As... (or similar menu option). Share.
Read more >How to Save High-Quality Images in Photoshop - MakeUseOf
Changing the resolution also increases the image's dimensions above. If you change your width and height back to the original image size, the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Here is a solution I found:
Inspired by https://stackoverflow.com/a/51438809/6933377
Aha, the scalebar would not be pixelated, then, wrong assumption on my end…
I would increase the dots per inch (DPI), as you do, to ensure that you don’t loose much pixel resolution. Apart from that, I don’t know what else can help, unfortunately. It might be that just adding a custom scalebar in your program yourself is the simplest solution when you want to keep the exact image resolution.