plot
Draw publication-style ggplot2 charts from R session data. Supports histograms, density, box, violin, scatter, line, bar, QQ, and heatmap plots with grouping, faceting, and error bars.
Instructions
Draw a publication-style ggplot2 chart and return it as an image. Types: histogram, density, box, violin, scatter, line, bar, qq, heatmap.
x is the main variable (the grouping variable for box/violin plots), y the outcome, group adds colour, facet splits into panels. For scatter plots set smooth=true to overlay a fitted line; for bar plots giving y shows group means (with error_bars=true for standard errors) instead of counts. For anything more specific, write ggplot2 code in r_run.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | No | Main variable; the grouping variable for box/violin plots. | |
| y | No | Outcome variable. | |
| bins | No | Histogram bin count. | |
| data | Yes | Dataset name in the session. | |
| flip | No | Swap the axes. | |
| stat | No | Summary for bar charts with a `y`: mean or median. | mean |
| type | No | histogram, density, box, violin, scatter, line, bar, qq or heatmap. | scatter |
| xlab | No | X axis label. | |
| ylab | No | Y axis label. | |
| facet | No | Split into one panel per level of this column. | |
| group | No | Colour/fill by this column. | |
| log_y | No | Use a log scale on the y axis. | |
| title | No | Plot title. | |
| points | No | Overlay raw data points on a box plot, or markers on a line. | |
| smooth | No | Add a fitted line to a scatter plot. | |
| position | No | dodge, stack or fill, for grouped bars. | dodge |
| subtitle | No | Plot subtitle. | |
| save_path | No | Also write the plot to this path as PNG. | |
| sort_bars | No | Order bars by descending count. | |
| error_bars | No | Add standard-error bars to a summary bar chart. | |
| plot_width | No | Width in inches. | |
| plot_height | No | Height in inches. | |
| smooth_method | No | lm, loess, gam or glm. | lm |