{"spec_id":"scatter-marginal","library":"seaborn","language":"python","code":"\"\"\" anyplot.ai\nscatter-marginal: Scatter Plot with Marginal Distributions\nLibrary: seaborn 0.13.2 | Python 3.13.13\nQuality: 91/100 | Updated: 2026-05-09\n\"\"\"\n\nimport numpy as np\nimport seaborn as sns\n\n\n# Data - correlated bivariate data to demonstrate scatter + marginal distributions\nnp.random.seed(42)\nn_points = 200\nx = np.random.randn(n_points) * 15 + 50\ny = 0.7 * x + np.random.randn(n_points) * 10 + 20\n\n# Create jointplot with scatter and marginal histograms+KDE\nsns.set_context(\"talk\", font_scale=1.4)\ng = sns.jointplot(\n    x=x,\n    y=y,\n    kind=\"scatter\",\n    height=12,\n    ratio=5,\n    marginal_kws={\"bins\": 25, \"kde\": True, \"color\": \"#306998\", \"alpha\": 0.7},\n    joint_kws={\"s\": 150, \"alpha\": 0.65, \"color\": \"#306998\", \"edgecolor\": \"white\", \"linewidth\": 0.5},\n)\n\n# Style the central scatter plot\ng.ax_joint.set_xlabel(\"X Value\", fontsize=22)\ng.ax_joint.set_ylabel(\"Y Value\", fontsize=22)\ng.ax_joint.tick_params(axis=\"both\", labelsize=16)\ng.ax_joint.grid(True, alpha=0.3, linestyle=\"--\")\n\n# Style marginal plots\ng.ax_marg_x.tick_params(axis=\"both\", labelsize=14)\ng.ax_marg_y.tick_params(axis=\"both\", labelsize=14)\n\n# Add title to figure\ng.figure.suptitle(\"scatter-marginal · seaborn · pyplots.ai\", fontsize=26, y=0.98)\ng.figure.subplots_adjust(top=0.92)\n\n# Save at high resolution\ng.figure.savefig(\"plot.png\", dpi=300, bbox_inches=\"tight\")\n"}