I was trying to visualise a result of linear regression. And I wanted to remove the top and right grey line. I have tried setting stroke=None, strokeWidth=0 and strokeOpacity=0 in global config but none of these worked. How can I get rid of them? Here’s my code and plot.
JavaScript
x
28
28
1
import altair as alt
2
import pandas as pd
3
import numpy as np
4
import matplotlib.pyplot as plt
5
alt.renderers.enable('altair_viewer')
6
alt.data_transformers.disable_max_rows()
7
8
df = pd.read_csv('~/Desktop/py/ukb.csv')
9
10
chart = alt.Chart(df).mark_point(color='gray', opacity=0.1).encode(
11
alt.X(
12
'loneliness:O',
13
axis=alt.Axis(title='Loneliness', grid=False, labelAngle=0)
14
),
15
alt.Y('v_rvlpfc:Q',
16
scale=alt.Scale(zero=False),
17
axis=alt.Axis(title='GMV of RVLPFC', grid=False)
18
)
19
).properties(
20
height=400,
21
width=400,
22
)
23
24
chart = chart + chart.transform_regression('loneliness','v_rvlpfc').mark_line(color='red')
25
chart.configure_view(stroke=None)
26
27
chart.show()
28
Advertisement
Answer
If you remove the last chart.show()
or do chart = chart.configure_view(stroke=None)
it will work. Currently you are not saving the modified chart.configure_view(stroke=None)
back to the chart
variable, and your last line displays the original chart
variable without any modification to the stroke.