Reputation: 41
On an Vegalite xy chart, how do I specify the data aspect ratio to 1? In other words, I want the same scaling from data to plot units for both x and y axes. In Matplotlib this is achieved with matplotlib.axes.Axes.set_aspect('equal'). How would I modify the following spec snippet?
{
"width": 500,
"height": 500
"mark": {"type": "line", "point": {"size": 0}},
"encoding": {
"x": {"field": "y", "type": "quantitative"},
"y": {"field": "x", "type": "quantitative"},
"color": {
"field": "run",
"type": "nominal",
"scale": {"scheme": "magma"}
}
}
}
Upvotes: 2
Views: 698
Reputation: 5310
Vega-lite and altair don't have an aspect argument or set_aspect method like in matplotlib. I had a same question earlier this week and this is the answer that I got from one of the devs;
It’s definitely possible to change the width/height of a figure, which is almost the same thing See https://altair-viz.github.io/gallery/aggregate_bar_chart.html for an example
So as long as your width and height have the same value then by default the aspect will also be equal.
Upvotes: 1