{"spec_id":"scatter-color-mapped","library":"plotnine","language":"python","code":"\"\"\" anyplot.ai\nscatter-color-mapped: Color-Mapped Scatter Plot\nLibrary: plotnine 0.15.4 | Python 3.13.13\nQuality: 85/100 | Updated: 2026-05-08\n\"\"\"\n\nimport numpy as np\nimport pandas as pd\nfrom plotnine import aes, element_text, geom_point, ggplot, labs, scale_color_cmap, theme, theme_minimal\n\n\n# Data - Temperature readings across a sensor grid\nnp.random.seed(42)\nn = 150\n\n# Sensor positions and temperature measurements\nx = np.random.uniform(0, 100, n)\ny = np.random.uniform(0, 100, n)\n# Temperature with spatial pattern - warmer in upper right\ntemperature = 20 + 0.15 * x + 0.1 * y + np.random.normal(0, 3, n)\n\ndf = pd.DataFrame({\"x_position\": x, \"y_position\": y, \"temperature\": temperature})\n\n# Create plot\nplot = (\n    ggplot(df, aes(x=\"x_position\", y=\"y_position\", color=\"temperature\"))\n    + geom_point(size=4, alpha=0.8)\n    + scale_color_cmap(cmap_name=\"viridis\")\n    + labs(\n        x=\"X Position (m)\",\n        y=\"Y Position (m)\",\n        color=\"Temperature (°C)\",\n        title=\"scatter-color-mapped · plotnine · pyplots.ai\",\n    )\n    + theme_minimal()\n    + theme(\n        figure_size=(16, 9),\n        text=element_text(size=14),\n        axis_title=element_text(size=20),\n        axis_text=element_text(size=16),\n        plot_title=element_text(size=24),\n        legend_text=element_text(size=14),\n        legend_title=element_text(size=16),\n    )\n)\n\n# Save\nplot.save(\"plot.png\", dpi=300)\n"}