「XY」で動くグラフを簡単に
Designing Scalable Interactive Visualizations with Reflex XY: Composition, Million-Point Rendering, Streaming, Custom Marks, and Export

Pythonの「XY」ライブラリを使うと、大量のデータを扱う動的なグラフを簡単に作成でき、複雑な情報も素早く理解できるようになります。
このチュートリアルでは、XY Python libraryの高度な可視化機能を探求し、インタラクティブでスケーラブル、かつ拡張可能なチャートを構築します。まず、XYのコンポジションモデルから始めます。ここでは、単一のチャート宣言内で複数のmarks、dual axes、annotations、tooltips、legends、themes、およびinteractive controlsを組み合わせます。次に、Pandas DataFrames、faceted layouts、linked viewports、そして効率的な探索のために自動的にdensity-based renderingに切り替わる百万点規模のデータセットを扱います。また、selectionsとcallbacksを通じてブラウザのインタラクションをPythonに接続し、streamingを通じてチャートを動的に更新し、DOM slotsとCSSで視覚コンポーネントをカスタマイズし、再利用可能なcustom trendline markでライブラリを拡張します。さらに、Matplotlib-compatible interfaceを使用し、可視化をstandalone HTML、SVG、およびPNGファイルとしてエクスポートします。Copy Code Copied Use a different Browser import subprocess, sys, os subprocess.run([sys.executable, "-m", "pip", "install", "-q", "xy"], check=True) WIDGETS_OK = True try: from google.colab import output as _colab_output _colab_output.enable_custom_widget_manager() except Exception: WIDGETS_OK = False import numpy as np import pandas as pd import xy from IPython.display import display, HTML print("xy", xy.__version__, "| live widgets:", WIDGETS_OK) def render(chart, note=""): if note: display(HTML(f"<h3 style='font:600 15px system-ui;margin:18px 0 6px'>{note}</h3>")) try: display(chart) except Exception: display(HTML(chart.to_html())) return chart rng = np.random.default_rng(7) days = np.arange(180) trend = 200 + 0.9 * days + 18 * np.sin(days / 9.0) revenue = trend + rng.normal(0, 12, days.size) sigma = 10 + 6 * np.abs(np.sin(days / 15.0)) conv = 0.06 + 0.02 * np.sin(days / 21.0) + rng.normal(0, 0.003, days.size) peak = int(np.argmax(revenue)) layered = xy.chart( xy.error_band(days, revenue - 1.96 * sigma, revenue + 1.96 * sigma, name="95% band", color="#7c3aed", opacity=0.16), xy.line(days, revenue, name="
この記事について質問
記事の内容に答えます。記事外のことは都度ウェブで調べます。