Scale bar does not correspond to the actual size
See original GitHub issueDear all, first of all, thank you very much for this, scalebars are kinda mandatory in research and having this in python is really nice. I am having some issues when using ScaleBar. The bar does not correspond to the actual size it would have; could you help me with that? I’m using this code:
from matplotlib_scalebar.scalebar import ScaleBar
from skimage.io import imread
len_px = 0.00048223304582578836
image = imread('dur_grain1apatite01.tif', as_grey=True)
fig, ax = plt.subplots(figsize=(15, 10))
ax.imshow(testimg_apatite)
scalebar = ScaleBar(dx=len_px,
units='mm',
fixed_value=25,
fixed_units='um',
location=4,
box_alpha=0,
font_properties={'family' : 'monospace',
'weight' : 'semibold',
'size' : 20})
fig.gca().add_artist(scalebar)
plt.show()
This is the example image. Thank you very much for your support.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
When scale bars don't scale - Exprodat
Traditionally, scale bars are based on the origin point of the map's ... Measurements taken north-south may not match with the scale bar....
Read more >Scale bars—ArcGIS Pro | Documentation
Scale bars provide a visual indication of the size of features and distance between features on the map.
Read more >The scale bar shows a wrong scale - qgis - GIS Stack Exchange
While working in QGIS' Layout Manager, you want to make sure that the scale bar is referred to a specific map which in...
Read more >Making the Scale Bar the Right Length in ArcMap - Esri
The scale bar you insert in ArcMap will be the correct length if your data do not extend much farther north and south...
Read more >Scale bar not showing up in TIFF image - YouTube
A solution to the scale bar not showing up in TIFF image format after saving in ImageJ. Here is a quick solution to...
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
I will close this issue not to cause confusion. Please reopen if you think the problem is still there.
Thank you both for your comment. You are 100% right there was a mistake in the code. After many attempts to understand the problem I realized that the “bar” of the scale bar was drawn with an edge around it 😞 This made the “bar” appeared longer. Making the bar longer (with the
length_fraction
) helped because the error due to the edge decreases as the length of the bar increases.I tried @parishcm’s example and I got a length of 10.0769 in ImageJ. I committed a fix and I will release a new version soon.