strip_plot
Create strip plots from SQL queries on CSV or Parquet data sources to visualize relationships between variables with optional color coding for additional dimensions.
Instructions
Run query against specified source and make a strip plot using result For both csv and parquet sources, use DuckDB SQL syntax Use 'CSV' as the table name in the SQL query for csv sources. Use 'PARQUET' as the table name in the SQL query for parquet sources.
This will return an image of the plot
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source_id | Yes | The data source to run the query on | |
| query | Yes | SQL query to run on the data source | |
| x | Yes | Column name from SQL result to use for x-axis | |
| y | Yes | Column name from SQL result to use for y-axis | |
| color | No | Optional column name from SQL result to show multiple colored strips representing another dimension |
Implementation Reference
- zaturn/tools/visualizations.py:159-192 (handler)The strip_plot tool handler: executes SQL query, generates strip plot with plotly px.strip, converts to PNG image via _fig_to_image, returns ImageContent or error string.def strip_plot(self, source_id: Annotated[ str, Field(description='The data source to run the query on') ], query: Annotated[ str, Field(description='SQL query to run on the data source') ], x: Annotated[ str, Field(description='Column name from SQL result to use for x-axis') ], y: Annotated[ str, Field(description='Column name from SQL result to use for y-axis') ], color: Annotated[ str | None, Field(description='Optional column name from SQL result to show multiple colored strips representing another dimension') ] = None, ) -> str | ImageContent: """ Run query against specified source and make a strip plot using result For both csv and parquet sources, use DuckDB SQL syntax Use 'CSV' as the table name in the SQL query for csv sources. Use 'PARQUET' as the table name in the SQL query for parquet sources. This will return an image of the plot """ try: df = self._get_df_from_source(source_id, query) fig = px.strip(df, x=x, y=y, color=color) fig.update_xaxes(autotickangles=[0, 45, 60, 90]) return _fig_to_image(fig) except Exception as e: return str(e)
- zaturn/tools/visualizations.py:29-40 (registration)Initial registration of strip_plot method in Visualizations.tools list.self.tools = [ self.scatter_plot, self.line_plot, self.histogram, self.strip_plot, self.box_plot, self.bar_plot, self.density_heatmap, self.polar_scatter, self.polar_line, ]
- zaturn/tools/__init__.py:7-10 (registration)ZaturnTools aggregates tools from core and visualizations, including strip_plot.self.tools = [ *core.Core(data_sources).tools, *visualizations.Visualizations(data_sources).tools, ]
- zaturn/mcp/__init__.py:91-94 (registration)Final MCP server registration loop adds all tools including strip_plot to FastMCP.zaturn_mcp = FastMCP() for tool_function in zaturn_tools.tools: zaturn_mcp.add_tool(Tool.from_function(tool_function))
- zaturn/tools/visualizations.py:13-22 (helper)Helper to convert Plotly figure to base64-encoded ImageContent PNG used by strip_plot.def _fig_to_image(fig): fig_encoded = b64encode(fig.to_image(format='png')).decode() img_b64 = "data:image/png;base64," + fig_encoded return ImageContent( type = 'image', data = fig_encoded, mimeType = 'image/png', annotations = None, )