question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scale bar does not correspond to the actual size

See original GitHub issue

Dear 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:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ppinardcommented, Jul 15, 2018

I will close this issue not to cause confusion. Please reopen if you think the problem is still there.

1reaction
ppinardcommented, Jul 8, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found