SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] Adding interactivity to an histogram in SVG

From: David H. <dav...@gm...> - 2011年08月23日 17:37:48
On Tue, Aug 23, 2011 at 11:29 AM, Michael Droettboom <md...@st...> wrote:
> On 08/23/2011 10:06 AM, David Huard wrote:
>>
>> You may want to try moving the "<defs>" containing the clipPath up a
>>> level, so it is a peer with the histogram rectangles.
>> Yep, that works.
>>
>>> That's just a stab in
>>> the dark. If that turns out that makes the difference, that should be an
>>> easy enough fix within matplotlib.
>> That would be great !
>
> I have a fix on this branch here:
>
> https://github.com/mdboom/matplotlib/tree/svg_references
>
> Would you mind testing it?
Works like a charm !
>
>> I'd be glad to contribute an example for the matplotlib gallery if
>> there is an interest. I think the SVG+JS combo has a lot of potential,
>> and matplotlib makes it easy.
>
> That would make a great addition. One small comment: I would put the
> "onclick" handler on the legend handles as well as the legend text. I
> tried to click the legend handles (with nothing happening) until I
> realized the "hotspot" was only on the text.
Right, done.
>
> For a long time, I have considered having a framework where arbitrary
> XML attributes can be assigned to artists and written out directly by
> the SVG writer to avoid the two-pass approach you're using here. (There
> is already support for assigning hyperlinks to SVG documents, but that
> could be made more general).
I thought about this too. There is already a set_gid method, so I
guess generalizing this to any (attribute, value) pair should not be
too hard. On the other hand, what would also help is more hierarchy
within the svg tree. At the moment, a group is created for figure,
axes, axis, legend and collections (from a quick overview, maybe there
are others.) However, since histogram returns flat patches instead of
a collection of patches, we need to loop through all bar patches to
set their properties. If histogram returned one patchcollection per
variable, we could address this group directly instead of the
individual elements.
> But that will require some careful design
> consideration etc. to get it done. In the meantime, it's useful having
> an example that shows how to do this using ElementTree to modify the SVG
> after matplotlib outputs it.
Good, I'll work on this then.
Thanks,
David
>
> Cheers,
> Mike
>
> ------------------------------------------------------------------------------
> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
> user administration capabilities and model configuration. Take
> the hassle out of deploying and managing Subversion and the
> tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
> _______________________________________________
> Matplotlib-devel mailing list
> 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 によって変換されたページ (->オリジナル) /