Skip to main content
Public

Share visualization

Loading preview…

Scatter Plot with Missing Data

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Scatter Plot with Missing Data

5
CCurran Kelleher
Last edited May 2, 2024
Created on Jan 29, 2024

This scatter plot visualizes the relationship between bill length and flipper length in penguins, using data from the `@curran/penguins` dataset. It demonstrates how to handle missing data by filtering out rows where either measurement is `NaN`, using JavaScript’s `Array.filter` and `isNaN`. The filtered data is rendered as semi-transparent points via `d3.select`, `d3.scaleLinear`, and `d3.axisLeft` within a D3.js SVG, with axis labels positioned by the `@curran/axis-labels` helper.

AI-generated description

A demonstration of how to filter out missing data, leveraging Array.filter and isNaN.

const filteredData = data.filter(
  (d) => !(isNaN(xValue(d)) || isNaN(yValue(d))),
);

Comments

Sign in to join the discussion.

MIT Licensed