Search code examples
pythonaltair

Altair remove border in LayerChart


I am trying to remove the border from an altair chart.
This answer works perfectly but it fails when I try to visualize a layered chart.

In my setting I have two charts, one for the contour m1 and one with the coordinates assigned to each category and properly colored m2.

I can add the setting configure_view(strokeWidth=0) to each and I can plot them independently, however when trying to plot m1+m2 I get an error.

Objects with "config" attribute cannot be used within LayerChart. Consider defining the config attribute in the LayerChart object instead.

I then defined m1 and m2without the config_view attribute but now I can't figure out how to define it for the final object.


Solution

  • Apparently it is as simple as creating a new object and setting the attribute on that object.

    layeredmap=m1+m2
    layeredmap.configure_view(StrokeWidth=0)
    

    Alternatively, it is enough to use parenthesis and define the attribute while plotting:

    (m1+m2).configure_view(StrokeWidth=0)