fc_cutoff and at the y position corresponding to p_cutoff.
Constructor
new()
Create a volcano plot with default settings.
Returns: VolcanoPlot
Defaults:
- fc_cutoff
1.0 - p_cutoff
0.05 - Firebrick/steelblue/gray colors
- Point size
3.0 - No labels
- No legend
Adding Data
with_point()
Add a single point by name, log₂FC, and raw p-value.
Gene or feature name, shown as a label when selected
Log₂ fold change on the x-axis
Raw p-value (not −log10). Zero p-values are handled automatically.
Self
Useful when building a plot incrementally. For bulk input prefer with_points.
with_points()
Add multiple points from an iterator of (name, log2fc, pvalue) tuples.
Iterator of tuples containing (name, log2fc, pvalue). Accepts any types that implement
Into<String> / Into<f64>.Self
This is the primary input method.
Thresholds
with_fc_cutoff()
Set the absolute log₂FC threshold for up/down classification.
Absolute log₂FC threshold (default: 1.0 — corresponding to a 2× fold change)
Self
Dashed vertical lines are drawn at ±fc_cutoff. Points with |log2FC| < fc_cutoff are always shown as not-significant regardless of their p-value.
with_p_cutoff()
Set the p-value significance threshold.
P-value threshold (default: 0.05)
Self
A dashed horizontal line is drawn at −log10(p_cutoff). Points with pvalue > p_cutoff are shown as not-significant regardless of their fold change.
Colors
with_color_up()
Set the color for up-regulated points.
CSS color string (default:
"firebrick")Self
A point is up-regulated when log2fc ≥ fc_cutoff and pvalue ≤ p_cutoff.
with_color_down()
Set the color for down-regulated points.
CSS color string (default:
"steelblue")Self
A point is down-regulated when log2fc ≤ −fc_cutoff and pvalue ≤ p_cutoff.
with_color_ns()
Set the color for not-significant points.
CSS color string (default:
"#aaaaaa")Self
All points that do not meet both the fold-change and p-value thresholds are drawn in this color.
Point Styling
with_point_size()
Set the circle radius in pixels.
Circle radius (default: 3.0)
Self
Gene Labels
with_label_top()
Label the n most significant points (lowest p-values) with their names.
Number of points to label (default: 0 — no labels)
Self
Use with_label_style to control placement.
with_label_style()
Set the label placement style.
Label placement style. Options:
LabelStyle::Nudge (default), LabelStyle::Exact, LabelStyle::Arrow { offset_x, offset_y }Self
LabelStyle::Nudge— labels are sorted by x and nudged vertically to reduce overlap. Best default for most datasets.LabelStyle::Exact— labels are placed at the exact point position with no adjustment. May overlap on dense plots.LabelStyle::Arrow— labels are offset by(offset_x, offset_y)px with a gray leader line back to the point.
P-Value Floor
with_pvalue_floor()
Set an explicit p-value floor for the −log10 transform.
Minimum p-value for transformation
Self
Points with pvalue == 0.0 are clamped to this value before transformation, preventing infinite y positions. Also sets the y-axis ceiling to −log10(floor).
When not set, the floor is inferred as the minimum non-zero p-value in the data. Set it explicitly when comparing multiple plots that should share the same y-axis scale.
Legend
with_legend()
Enable a legend showing Up, Down, and NS entries.
Legend title (currently not displayed but required to enable the legend)
Self
The legend uses the active up/down/NS colors.
Utility Methods
floor()
Compute the p-value floor used for -log10 transformation.
Returns: f64
Uses explicit floor if set, otherwise finds minimum non-zero p-value.
Complete Example
LabelStyle Enum
Variants
Exact
Label placed at the exact point position — no nudge, no leader line. Labels may overlap when many points are clustered together.
Nudge
Labels sorted by x position and nudged vertically to reduce stacking (default). This is the most readable option for dense data.
Arrow { offset_x: f64, offset_y: f64 }
Label offset by (offset_x, offset_y) pixels with a short gray leader line drawn from the offset position back to the point.
Public Fields
All data points
|log₂FC| threshold for up/down classification (default: 1.0)
P-value threshold for significance (default: 0.05)
Color for up-regulated points (default:
"firebrick")Color for down-regulated points (default:
"steelblue")Color for not-significant points (default:
"#aaaaaa")Circle radius in pixels (default: 3.0)
Number of most-significant points to label (default: 0)
Label placement style (default:
LabelStyle::Nudge)Explicit p-value floor for the −log10 transform. When
None, the minimum non-zero p-value in the data is used automatically.When
Some, a legend box shows Up / Down / NS entries