- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Deneb: Distribution curve on bar diagram
Hi, need some help on what I am doing wrong here.
The end-goal I wish to achive is a distribution curve combined with histogram.
I have been looking into the use of density in deneb but do not seem to get it right.
Code below
{
"data": {"name": "dataset"},
"layer": [
{
"description": "Histogram Bars",
"mark": {
"type": "bar",
"color": "#7DA7D9",
"tooltip": true
},
"encoding": {
"x": {
"bin": {"maxbins": 40},
"field": "Diameter",
"type": "quantitative",
"scale": {
"domain": [7.82, 7.87]
},
"axis": true,
"title": ""
},
"y": {
"aggregate": "count",
"type": "quantitative",
"axis": {"labels": false},
"title": "Count"
}
}
},
{
"description": "Histogram line",
"transform": [
{
"density": "Diameter",
"bandwidth": 0.3
}
],
"mark": {
"type": "line",
"color": "#931313",
"strokeWidth": 2
},
"encoding": {
"x": {
"field": "value",
"type": "quantitative"
},
"y": {
"field": "density",
"type": "quantitative"
}
}
}
],
"resolve": {
"scale": {"y": "independent"}
}
}
Any ideas where the problem is?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@KerKol, I adjusted the bandwith to match the standard deviation for the data sample used and got the following result.
@KerKol wrote:sounds like you may have found the issue, the above curve looks about right.
You have the Y aggregated as a count for your bars, but perhaps not for your line. What happens if you adjust the aggregation?
For the y-axis of the bars I use the aggregate: "count" and for y-axis I use "field": "density".
I am curious about what you mean by "adjust the aggregation".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code works for me on my own data. What happens when you set resolve to dependent?
And remove the domain scale?
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@KerKol thanks for your suggestions but it did not help...
When I set to dependent it moves sligthly along the x-axis.
When I also remove the domain scale the bar streches out along the x-axis. In both cases the line is still not changing.
How about the "x": {"field" : "value"}... What is really inside "value", how can its content be verified or changed?
I tried changing the bandwith since Diameter has several decimals and started to get some effect..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sounds like you may have found the issue, the above curve looks about right.
You have the Y aggregated as a count for your bars, but perhaps not for your line. What happens if you adjust the aggregation?
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@KerKol, I adjusted the bandwith to match the standard deviation for the data sample used and got the following result.
@KerKol wrote:sounds like you may have found the issue, the above curve looks about right.
You have the Y aggregated as a count for your bars, but perhaps not for your line. What happens if you adjust the aggregation?
For the y-axis of the bars I use the aggregate: "count" and for y-axis I use "field": "density".
I am curious about what you mean by "adjust the aggregation".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Привет, мне так же интересна эта тема. Разместите полный код JSON, спасибо!

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
04-12-2023 03:13 AM | |||
Anonymous
| 02-19-2024 04:50 AM | ||
06-07-2025 05:14 AM | |||
Anonymous
| 04-14-2020 08:02 AM | ||
05-05-2025 09:12 AM |
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |