Vega-Lite 的一些预测在 Altair 中不起作用
Some projections from Vega-Lite do not work in Altair
根据堆栈跟踪,我可以看到 Altair 只接受以下投影 -
['albers', 'albersUsa', 'azimuthalEqualArea', 'azimuthalEquidistant', 'conicConformal', 'conicEqualArea', 'conicEquidistant', 'equalEarth', 'equirectangular', 'gnomonic', 'identity', 'mercator', 'naturalEarth1', 'orthographic', 'stereographic', 'transverseMercator']
但是,我真的很想有一个基于多面体的投影,Cahill-Keyes specifically. After a bit of searching I found this page where I can see all the Vega-Lite projections - https://observablehq.com/@vega/vega-lite-cartographic-projections
它确实有一些多面体投影。
然而,Altair 似乎不支持其中的很多。我认为通常 Vega-Lite 中可用的任何东西都可以使用 Altair 完成,所以我想知道为什么 Altair 限制了投影的数量?
Altair 遵循 Vega-Lite schema。
Vega-Lite 在 ProjectionType
定义中列出支持的投影;据此,允许的投影类型如下:
"ProjectionType": {
"enum": [
"albers",
"albersUsa",
"azimuthalEqualArea",
"azimuthalEquidistant",
"conicConformal",
"conicEqualArea",
"conicEquidistant",
"equalEarth",
"equirectangular",
"gnomonic",
"identity",
"mercator",
"naturalEarth1",
"orthographic",
"stereographic",
"transverseMercator"
],
"type": "string"
},
如果您指定的投影与其中之一不匹配,Altair 将引发错误。
使用一些技巧,您可以使用 vega-projection-extended
项目来获得更多投影。不过还是有一些问题,引用 Jeffrey Heer 在 Observable site 上的话,您可以在其中看到这些预测的实际效果 -
Note that some projections may show artifacts due to a lack of clipping to the sphere of the globe. We're working on it!
在 Jupyter Notebook 中使用 Altair,您可能无法使用它。但是,如果您确定某个投影,则可以导出 HTML 或 json 规范并添加 vega-projection-extended
库并将现有投影替换为您想要的投影。瞧,Vega-Lite 将显示投影。
您可以将投影库添加为-
<script src="https://cdn.jsdelivr.net/npm/vega-projection-extended@2"></script>
并且在 vegaEmbed 规范中,您可以将投影名称更改为 -
......."projection": {"type": "interruptedBoggs"}
根据堆栈跟踪,我可以看到 Altair 只接受以下投影 -
['albers', 'albersUsa', 'azimuthalEqualArea', 'azimuthalEquidistant', 'conicConformal', 'conicEqualArea', 'conicEquidistant', 'equalEarth', 'equirectangular', 'gnomonic', 'identity', 'mercator', 'naturalEarth1', 'orthographic', 'stereographic', 'transverseMercator']
但是,我真的很想有一个基于多面体的投影,Cahill-Keyes specifically. After a bit of searching I found this page where I can see all the Vega-Lite projections - https://observablehq.com/@vega/vega-lite-cartographic-projections 它确实有一些多面体投影。
然而,Altair 似乎不支持其中的很多。我认为通常 Vega-Lite 中可用的任何东西都可以使用 Altair 完成,所以我想知道为什么 Altair 限制了投影的数量?
Altair 遵循 Vega-Lite schema。
Vega-Lite 在 ProjectionType
定义中列出支持的投影;据此,允许的投影类型如下:
"ProjectionType": {
"enum": [
"albers",
"albersUsa",
"azimuthalEqualArea",
"azimuthalEquidistant",
"conicConformal",
"conicEqualArea",
"conicEquidistant",
"equalEarth",
"equirectangular",
"gnomonic",
"identity",
"mercator",
"naturalEarth1",
"orthographic",
"stereographic",
"transverseMercator"
],
"type": "string"
},
如果您指定的投影与其中之一不匹配,Altair 将引发错误。
使用一些技巧,您可以使用 vega-projection-extended
项目来获得更多投影。不过还是有一些问题,引用 Jeffrey Heer 在 Observable site 上的话,您可以在其中看到这些预测的实际效果 -
Note that some projections may show artifacts due to a lack of clipping to the sphere of the globe. We're working on it!
在 Jupyter Notebook 中使用 Altair,您可能无法使用它。但是,如果您确定某个投影,则可以导出 HTML 或 json 规范并添加 vega-projection-extended
库并将现有投影替换为您想要的投影。瞧,Vega-Lite 将显示投影。
您可以将投影库添加为-
<script src="https://cdn.jsdelivr.net/npm/vega-projection-extended@2"></script>
并且在 vegaEmbed 规范中,您可以将投影名称更改为 -
......."projection": {"type": "interruptedBoggs"}