See here for the example code that generated this page

ScatterPlot Examples

This page demonstrates 2D scatter plots with marginal distributions in JSPlots.




Multi-Dimensional Health Data

Use the X and Y dropdowns to explore different dimension combinations. Try: mass vs height, age vs bmi, etc. Marginal distributions show on both axes.

Plot Attributes

Axes

1.0 (0.25 - 2.5)

Data: df1




Multiple Styling Options

Use the Color dropdown to change visual encoding. Try different combinations to highlight different aspects of the data.

Plot Attributes

Axes

1.0 (0.25 - 2.5)

Data: df2




Faceting Example - Weather Data

Use the 'Facet by' dropdown to split the data. Notice: Marginal distributions appear when no faceting is selected, but disappear when a facet is applied to save space.

Plot Attributes

Axes

Facets

1.0 (0.25 - 2.5)

Data: df3




Two-Dimensional Faceting - Student Performance

Uses Facet 1 and Facet 2 to create a grid of subplots. Default shows grade × major. Try different combinations like semester × major. Set either facet to 'None' to reduce to single facet or no faceting.

Plot Attributes

Axes

Facets

1.0 (0.25 - 2.5)

Data: df4




Complex Multi-Dimensional Exploration

Demonstrates all features together: 4 dimensions for X/Y axes, multiple color options, and faceting. Explore different combinations to find interesting patterns.

Plot Attributes

Axes

Facets

1.0 (0.25 - 2.5)

Data: df5




Time Series Scatter with Filters

Use date and quarter filters to focus on specific time periods. Points are colored by portfolio to show different investment trajectories.

Filters

1 - 2

Plot Attributes

Axes

1.0 (0.25 - 2.5)

Data: df6




Example 7: Single-Select Choice vs Multi-Select Filter

This example demonstrates the difference between choices and filters: - **portfolio (choice)**: Single-select dropdown - pick exactly ONE portfolio - **quarter (filter)**: Multi-select dropdown - can select multiple quarters Use choices when the user must select exactly one option (e.g., pick one portfolio to analyze). Use filters when multiple selections make sense (e.g., view data from several quarters).

Filters

1 - 2

Plot Attributes

Axes

1.0 (0.25 - 2.5)

Data: df6




Struct Data Source Example

This scatter plot uses data from a struct containing multiple DataFrames. The ExperimentData struct holds both measurements and metadata. Charts reference the measurements DataFrame using Symbol("experiment.measurements").




Example 8: Experiment Measurements from Struct Data Source

This example shows how to use a struct as a data source. The ExperimentData struct contains measurements and metadata DataFrames. Access struct fields via dot notation.

Plot Attributes

Axes

1.0 (0.25 - 2.5)

Data: experiment.measurements




Expression Mode Examples

The following examples demonstrate expression_mode=true, which allows users to type custom expressions for the X axis. This is useful for creating computed variables on-the-fly.

Available functions: z(), q(), PCA1(), PCA2(), r(), f(), c()




Example 9: Expression Mode - Z-Score Within Groups

X axis shows z-score of returns within each sector. Try: z(:returns, [:sector, :region]) for nested groups, or just :returns for raw values.

Filters

Plot Attributes

Axes

Expression Syntax Guide
Variables: :varname or varname
Reference any column from your data
Operators: + - * /
Combine variables arithmetically
Available Functions
z(expr, [groups]) Z-score (standardize) within groups. Example: z(:returns, [:sector, :date])
q(expr, [groups]) Quantile rank (0-1) within groups. Example: q(:returns, [:sector])
PCA1(:v1, :v2) Project onto first principal component of v1 and v2
PCA2(:v1, :v2) Project onto second principal component of v1 and v2
r(y, x) OLS residual: y minus fitted value from regressing y on x
f(y, x) OLS fitted value: predicted y from regressing y on x
c(expr, min, max) Clamp values between min and max. Use Inf/-Inf for one-sided bounds. Example: c(:returns, -0.05, 0.05)
Examples: :returns + :volatility z(:returns, [:sector]) c(:vol, -Inf, 0.5)
1.0 (0.25 - 2.5)

Data: df9




Example 10: Expression Mode - OLS Residuals

X = residuals from regressing returns on market_returns (idiosyncratic returns). Try: f(:returns, :market_returns) for fitted values, or :returns - f(:returns, :market_returns).

Filters

Plot Attributes

Axes

Expression Syntax Guide
Variables: :varname or varname
Reference any column from your data
Operators: + - * /
Combine variables arithmetically
Available Functions
z(expr, [groups]) Z-score (standardize) within groups. Example: z(:returns, [:sector, :date])
q(expr, [groups]) Quantile rank (0-1) within groups. Example: q(:returns, [:sector])
PCA1(:v1, :v2) Project onto first principal component of v1 and v2
PCA2(:v1, :v2) Project onto second principal component of v1 and v2
r(y, x) OLS residual: y minus fitted value from regressing y on x
f(y, x) OLS fitted value: predicted y from regressing y on x
c(expr, min, max) Clamp values between min and max. Use Inf/-Inf for one-sided bounds. Example: c(:returns, -0.05, 0.05)
Examples: :returns + :volatility z(:returns, [:sector]) c(:vol, -Inf, 0.5)
1.0 (0.25 - 2.5)

Data: df10




Example 11: Expression Mode - Clamp for Outliers

X = raw_value clamped between -30 and 30 to limit outlier impact. Try: c(:raw_value, -Inf, 20) for max-only, or c(:raw_value, -20, Inf) for min-only.

Plot Attributes

Axes

Expression Syntax Guide
Variables: :varname or varname
Reference any column from your data
Operators: + - * /
Combine variables arithmetically
Available Functions
z(expr, [groups]) Z-score (standardize) within groups. Example: z(:returns, [:sector, :date])
q(expr, [groups]) Quantile rank (0-1) within groups. Example: q(:returns, [:sector])
PCA1(:v1, :v2) Project onto first principal component of v1 and v2
PCA2(:v1, :v2) Project onto second principal component of v1 and v2
r(y, x) OLS residual: y minus fitted value from regressing y on x
f(y, x) OLS fitted value: predicted y from regressing y on x
c(expr, min, max) Clamp values between min and max. Use Inf/-Inf for one-sided bounds. Example: c(:returns, -0.05, 0.05)
Examples: :returns + :volatility z(:returns, [:sector]) c(:vol, -Inf, 0.5)
1.0 (0.25 - 2.5)

Data: df11




Example 12: Expression Mode - Combined Functions

X = z-score of clamped returns within sector. Clamp first to reduce outlier impact, then standardize. Try: c(z(:returns, [:sector]), -2, 2) to clamp z-scores instead.

Filters

Plot Attributes

Axes

Expression Syntax Guide
Variables: :varname or varname
Reference any column from your data
Operators: + - * /
Combine variables arithmetically
Available Functions
z(expr, [groups]) Z-score (standardize) within groups. Example: z(:returns, [:sector, :date])
q(expr, [groups]) Quantile rank (0-1) within groups. Example: q(:returns, [:sector])
PCA1(:v1, :v2) Project onto first principal component of v1 and v2
PCA2(:v1, :v2) Project onto second principal component of v1 and v2
r(y, x) OLS residual: y minus fitted value from regressing y on x
f(y, x) OLS fitted value: predicted y from regressing y on x
c(expr, min, max) Clamp values between min and max. Use Inf/-Inf for one-sided bounds. Example: c(:returns, -0.05, 0.05)
Examples: :returns + :volatility z(:returns, [:sector]) c(:vol, -Inf, 0.5)
1.0 (0.25 - 2.5)

Data: df9


This page was created using JSPlots.jl v0.6.3.