Forum Discussion
Wind Direction Aster Plot
Happy to use alternative plot.
The categories on that plot still need shifting so that "N" is at the north point of the diagram, and so forth. In addition - can the position of the category boundaries be altered within the circle? At the moment for example, "N" would "start" at 0 degrees whereas in fact (with my direction categories defined as they are) it would need to span 348.75 - 11.25 degrees - as below.
dm-p can you please help me over the hump? I found theta but don't know how to draw partial arcs.
- dm-p3 years agoSuper User
Hi lbendlin - you also have theta2 (end angle) available for encoding. Here's the doc link (with interactive example).
- lbendlin3 years agoSuper User
Hmm. Can't seem to get it to turn the right way, even with the theta adjustments. Also tried to add placeholders for the missing directions.
{ "data": {"name": "dataset"}, "layer": [ { "mark": { "type": "arc", "innerRadius": 20, "stroke": "#444" } }, { "mark": { "type": "text", "radiusOffset": 50 }, "encoding": { "text": { "field": "Direction", "type": "nominal" } } } ], "encoding": { "theta": { "field": "Theta", "type": "quantitative", "stack": false }, "theta2": { "field": "Theta2", "type": "quantitative", "stack": false }, "radius": { "field": "Sum of Count", "scale": { "type": "sqrt", "zero": true } }, "color": { "field": "Direction", "type": "nominal", "legend": true } } }- dm-p3 years agoSuper User
Hi lbendlin,
If you want to explicitly bind the theta (and theta2) values to the radian representation from the data, you will need to use the value definition in the encoding (which maps the explicit value). If you bind a field, Vega-Lite will work out the angle based on the range of values from minimum to maximum (although you could probably manually set the range and domain on the scale to match the radian value, if you specifically wanted to still use the field definition).
Not sure if this is exactly what you're after but may get you closer:
{ "data": {"name": "dataset"}, "layer": [ { "mark": { "type": "arc", "innerRadius": 20, "stroke": "#444" } }, { "mark": { "type": "text", "radiusOffset": 50 }, "encoding": { "text": { "field": "Direction", "type": "nominal" } } } ], "encoding": { "theta": { "value": {"expr": "datum['Theta']"}, "type": "quantitative", "stack": false }, "theta2": { "value": {"expr": "datum['Theta2']"}, "type": "quantitative" }, "radius": { "field": "Sum of Count", "scale": { "type": "sqrt", "zero": true } }, "color": { "field": "Direction", "type": "nominal" } } }Cheers,
Daniel