import altair as alt
import pandas as pd
# assign data of lists.
ProxyData = {'Separation Mechanism': ['Force1', 'Force2', 'Force3', 'Force4', 'Force5',
'Force6' ], 'Parm1':[1,100,2.5,38,20,30], 'Parm2':[300,1000,150,1500,1000,1300], 'Parm3':
[0.1,30,7.5,1,30,270],'Parm4':[81650,9000,2000,4000,2000,1540] }
# Create DataFrame
df3 = pd.DataFrame(ProxyData)
base =alt.Chart(df3).mark_bar(opacity=0.5).encode(
alt.X('Parm1', scale=alt.Scale(type='log'), axis = alt.Axis(title='Particle')),
x2='Parm2',
y=alt.Y('Parm4',sort = None, scale=alt.Scale(type='log'), axis = alt.Axis(title='Rate')),
y2 = 'Parm3'
).properties(width = 500, height = 400
)
bars = base.mark_bar(opacity=0.5).encode(
color= alt.Color('Separation Mechanism', scale=alt.Scale(scheme='accent'))
)
text = base.mark_text(
align='right',
baseline='middle',
color='black',
dx=100, dy =3, fontSize = 14).encode(text='Separation Mechanism')
bars+text
The link here describes the label transformation in javascript but I want adapt it for python Online Altair documentation on label transformation I have tried to include .transform(avoidMarks = ["Force5", "Force6"]) to "text" section but it shows error as undefined object not callable. I request you to kindly help me on how to use lable transform to avoid the overlapping text. Thank you very much.