Point mark¶
An interactive point chart with a quantitative color channel and a smooth relationship generated by GenomeSpy transforms.
Inputs and adaptation¶
Field |
Type |
Source |
|---|---|---|
|
Quantitative |
Prepared example positions loaded in Python. |
|
Quantitative |
Derived by GenomeSpy’s browser transforms. |
For your table, replace sincos_data() with the table supplied to gs.Chart;
the loader is an internal gallery fixture. Update the x field and axis title.
Keep the formulas only if those functions are the intended measurements;
otherwise encode your existing y/color columns and remove the formulas.
Expected here: point height follows sin(x / 4), color follows cos(x / 5),
and numeric x/y scales allow zoom. No statistical analysis runs in Python.
Code¶
"""Point mark.
An interactive point chart with a quantitative color channel and a smooth
relationship generated by GenomeSpy transforms.
"""
import genome_spy as gs
from genome_spy.datasets._grammar import sincos_data
# Load example positions along the horizontal axis.
data = sincos_data()
# Calculate a sine wave for point height and a cosine wave for color.
chart = (
gs.Chart(data)
.transform_calculate(
sin=gs.expr.sin(gs.datum.x / 4),
cos=gs.expr.cos(gs.datum.x / 5),
)
# Use partly transparent circles so overlapping points remain visible.
.mark_point(size=60, filled=True, opacity=0.75)
.encode(
x=gs.X("x:Q").scale(zoom=True).title("Position"),
y=gs.Y("sin:Q").scale(zoom=True).title("sin(x / 4)"),
color=gs.Color("cos:Q").title("cos(x / 5)"),
)
.properties(title="Point mark")
)