SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] scalebars

From: Matěj T. <mat...@gm...> - 2012年11月21日 12:12:25
Thank you for your fast reply,
you are right, AnchoredSizeBar has indeed almost all features I would
like. Or it definitely has the most important ones.
I have stumbled upon the page you refer, but I must have overlooked it.
An actual documentation of the function wouldn't hurt
Anyway, these features seem to be missing:
 - Bar styles (bar width, bar endings wouldn't hurt either).
 - Colors (bar, text, background).
I would like to look into it, but it is usually more efficient if more
experienced persons provide some pointers. So if you think that I should
know something before attempting to add the functionality, please let me
know.
For instance, do you think that the enhancements I have proposed make
sense and should be integrated into AnchoredSizeBar?
Matej
On 11/18/2012 06:32 PM, Joe Kington wrote:
> Have you had a look at "AnchoredSizeBar" from 
> mpl_toolkits.axes_grid1.anchored_artists?
>
> http://matplotlib.org/1.1.1/mpl_toolkits/axes_grid/users/overview.html#anchoredartists
>
> It provides essentially all of the features you mention. I'd agree it 
> could use a few enhancements, but it's a good start on this.
>
> As a quick example of using it as you describe:
>
> import matplotlib.pyplot as plt
> import numpy as np
> from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
>
> fig, ax = plt.subplots()
> ax.imshow(np.random.random((10,10)))
>
> bar = AnchoredSizeBar(ax.transData, 2, '2 Units',
> pad=0.5, loc=8, sep=5, borderpad=0.5, frameon=True)
> bar.patch.set(alpha=0.5, boxstyle='round')
> ax.add_artist(bar)
>
> plt.show()
>
>
> Note that this is very similar to your example. The main things it's 
> missing are ends on the scalebar.
>
> I'd certainly agree that it could use some enhancements (e.g. 
> different styles of scalebars and better documentation), but perhaps 
> it's best to start with AnchoredSizeBar instead of recreating it from 
> scratch?
>
> Just my thoughts, anyway.
> -Joe
>
>
> On Sun, Nov 18, 2012 at 8:16 AM, Matěj Týč <mat...@gm... 
> <mailto:mat...@gm...>> wrote:
>
> Dear developers,
> I use Matplotlib to process and display images acquired by
> microscopes.
> It is quite common to indicate dimensions by displaying scale bar
> in the
> image rather than using axes with labels. Although axes enable you to
> refer to specific location in the image, they take up space around the
> image, so if you only need to show the scale, scale bar is better.
>
> What is needed:
> - The scale bar of given dimension (data units), possibly with
> bars at
> its ends.
> - Text (presumably centered under the bar), text size as well as
> vertical offset in physical units (= units reflecting the actual image
> size, like the font size)
> - Semi-transparent rectangle, so the scale and label are more
> readable
> - Dark/bright theme might be a good idea.
> I have made an svg file in Inkscape, so you can see what I mean.
>
> First of all, I tried to implement the stuff myself, but later I have
> found out that there is something on github. I have forked it,
> made some
> minor modifications, and I think that it is "almost done".
> https://gist.github.com/4100881 (the add_scalebar function there is
> broken ATM)
> I also attach the test code for your convenience. You need to run it
> with scalebars.py in the same directory.
> You are supposed to see a tiny bright scalebar at the bottom right
> corner.
>
> There are some outstanding issues, though:
>
> - I have a feeling that bars at the end of the scale bar should be
> related to the font size, as well as the actual width of the scale
> bar.
> How to achieve this?
> - How to make the semi-transparent background for the bar and
> label in
> a smart way?
>
> Could you help me with those? I would like this to appear in
> matplotlib
> since it is IMO a useful feature, what needs to be done?
> Regards,
> Matěj Týč
>
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases,
> vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from 795ドル for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> _______________________________________________
> Matplotlib-devel mailing list
> Mat...@li...
> <mailto:Mat...@li...>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
>

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /