Skip to content

Instantly share code, notes, and snippets.

@ijlyttle
Last active September 17, 2018 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ijlyttle/8cce9bf5458d4e10b4de1e828e4eade1 to your computer and use it in GitHub Desktop.
Save ijlyttle/8cce9bf5458d4e10b4de1e828e4eade1 to your computer and use it in GitHub Desktop.
Boxplot using temporal/ordinal variable
license: mit
height: 500
scrolling: yes
border: yes

I have three issues with the boxplot:

  1. The formatting directive for the x-axis labels is not being taken into account.
  2. The boxplots don't seem "right".
  3. The outliers are not appearing in the boxplot. (But I could be doing something wrong.)
<!DOCTYPE html>
<html>
<head>
<!-- uploaded using vegawidget -->
<script src="https://cdn.jsdelivr.net/npm/vega@4.2.0"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@3.0.0-rc6"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3.19.2"></script>
<link rel="stylesheet" type="text/css" href="vega-embed.css">
</head>
<body>
<div id="vis"></div>
<script type="text/javascript">
const spec = "spec.json";
const opt = {"defaultStyle":true,"renderer":"canvas"};
vegaEmbed('#vis', spec, opt).then(function(result) {
// access view as result.view
}).catch(console.error);
</script>
</body>
</html>
{
"$schema": "https://vega.github.io/schema/vega-lite/v3.json",
"data": {
"url": "https://vega.github.io/vega-datasets/data/seattle-weather.csv",
"format": {
"type": "csv"
}
},
"hconcat": [
{
"mark": {
"type": "boxplot",
"extent": 1.5
},
"encoding": {
"x": {
"field": "date",
"timeUnit": "month",
"type": "ordinal",
"axis": {
"format": "%b"
}
},
"y": {
"field": "temp_max",
"type": "quantitative"
}
}
},
{
"mark": {
"type": "point"
},
"encoding": {
"x": {
"field": "date",
"timeUnit": "month",
"type": "ordinal",
"axis": {
"format": "%b"
}
},
"y": {
"field": "temp_max",
"type": "quantitative"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment