|
|
|||||||||||||||||||||||||||||
|
matplotlib widgets_Examples 26_svg_histogram. |
H.Kamifuji . |
|
凡例マーカーをクリックしてバーを非表示にするかインタラクティブなヒストグラムを作成する方法を示します。 対話性は ecmascript(javascript)でエンコードされ、後処理ステップで SVG コードに挿入されます。 イメージをレンダリングするには、Web ブラウザでイメージを開きます。 SVG は、Linux および OSX ユーザーが使用するほとんどの Web ブラウザでサポートされています。 Windows IE9 は SVG をサポートしていますが、以前のバージョンは SVG をサポートしていません。 注意: matplotlib バックエンドは各オブジェクトに id を割り当てることができます。 これは、Python で作成された matplotlib オブジェクトと、2 番目のステップで解析される対応する SVG 構文を関連付けるためにここで使用されるメカニズムです。 フレキシブルではあるが、オブジェクトの大量収集には ID を使用するのが厄介です。 物を簡略化するために2つのメカニズムを使用することができます。 *オブジェクトを SVG <g> タグに体系的にグループ化し、 *各SVGオブジェクトの原点に応じてクラスを割り当てます。 たとえば、個々のバーのプロパティを変更する代わりに、`hist` 関数のバーを PatchCollection にグループ化するか、class = "hist_##" 属性を割り当てることができます。 生成された SVG を通して繰り返しマークアップを置き換えるために、CSS をもっと広く使用することもできます。 """ Demonstrate how to create an interactive histogram, in which bars are hidden or shown by clicking on legend markers. The interactivity is encoded in ecmascript (javascript) and inserted in the SVG code in a post-processing step. To render the image, open it in a web browser. SVG is supported in most web browsers used by Linux and OSX users. Windows IE9 supports SVG, but earlier versions do not. Notes ----- The matplotlib backend lets us assign ids to each object. This is the mechanism used here to relate matplotlib objects created in python and the corresponding SVG constructs that are parsed in the second step. While flexible, ids are cumbersome to use for large collection of objects. Two mechanisms could be used to simplify things: * systematic grouping of objects into SVG |
|
Python 3.11.2 見直しました。上記のコードでは、下記のエラーが発生します。 svg_histogram.txt matplotlib 内部のエラーのようです。matplotlib の改修(先祖帰りバグの改修)を待つしかない。 Python 3.11.6 (matplotlib 3.7.1) では、下記のようなエラーがあり、実行できない。 Traceback (most recent call last): File "M:\______\svg_histogram.py", line 146, inPython 3.12.0 (matplotlib 3.8.1) では、下記のようなエラーがあり、実行できない。 Traceback (most recent call last): File "E:\______\svg_histogram.py", line 146, inPython 3.11.6 (matplotlib 3.7.1) 及び Python 3.12.0 (matplotlib 3.8.1) で、見直し中、新しいサンプル(user-interfaces-svg-histogram-sgskip-py) を見つけ、下記のコードで、正常に実行できました。 """ ============= SVG Histogram ============= Demonstrate how to create an interactive histogram, in which bars are hidden or shown by clicking on legend markers. The interactivity is encoded in ecmascript (javascript) and inserted in the SVG code in a post-processing step. To render the image, open it in a web browser. SVG is supported in most web browsers used by Linux and OSX users. Windows IE9 supports SVG, but earlier versions do not. Notes ----- The matplotlib backend lets us assign ids to each object. This is the mechanism used here to relate matplotlib objects created in python and the corresponding SVG constructs that are parsed in the second step. While flexible, ids are cumbersome to use for large collection of objects. Two mechanisms could be used to simplify things: * systematic grouping of objects into SVGPython 3.11.6 (matplotlib 3.7.1) 及び Python 3.12.0 (matplotlib 3.8.1) 共に、正常実行です。 |
|
widgets_Examples code: svg_histogram.py user-interfaces-svg-histogram-sgskip-py |
|