I'm trying to improve the following figure by giving the x axis different "sizes": Figure The periods of Manager1 and Manager2 are different (the first lasts around 5 years, and the 2nd, around 1.5 years). I'd like the sizes of the bar charts to refflect this difference. The data is the following:
import pandas as pd
from pandas import Timestamp
example_data = {'Responsible': {516: 'p1',
517: 'p2',
518: 'p3',
701: 'p4',
702: 'p5',
703: 'p6',
704: 'p7',
705: 'p8',
706: 'p9'},
'Manager': {516: 'Manager1',
517: 'Manager1',
518: 'Manager2',
701: 'Manager1',
702: 'Manager1',
703: 'Manager1',
704: 'Manager2',
705: 'Manager2',
706: 'Manager2'},
'start': {516: Timestamp('2011-07-28 00:00:00'),
517: Timestamp('2013-07-24 00:00:00'),
518: Timestamp('2016-07-28 00:00:00'),
701: Timestamp('2011-10-21 00:00:00'),
702: Timestamp('2013-07-24 00:00:00'),
703: Timestamp('2014-02-24 00:00:00'),
704: Timestamp('2016-07-28 00:00:00'),
705: Timestamp('2017-07-27 00:00:00'),
706: Timestamp('2018-01-09 00:00:00')},
'end': {516: Timestamp('2013-07-22 00:00:00'),
517: Timestamp('2016-07-28 00:00:00'),
518: Timestamp('2018-03-23 00:00:00'),
701: Timestamp('2013-07-22 00:00:00'),
702: Timestamp('2014-02-24 00:00:00'),
703: Timestamp('2016-07-28 00:00:00'),
704: Timestamp('2017-07-27 00:00:00'),
705: Timestamp('2018-01-09 00:00:00'),
706: Timestamp('2018-04-02 00:00:00')},
'gender': {516: 'M',
517: 'F',
518: 'M',
701: 'F',
702: 'F',
703: 'F',
704: 'F',
705: 'F',
706: 'M'},
'position': {516: 'Place1',
517: 'Place1',
518: 'Place1',
701: 'Place2',
702: 'Place2',
703: 'Place2',
704: 'Place2',
705: 'Place2',
706: 'Place2'}}
new_df = pd.DataFrame.from_dict(example_data)
The code is the following:
import altair as alt
rad = 10
alt.Chart(new_df).mark_bar(cornerRadiusTopLeft= rad,
cornerRadiusTopRight = rad,
cornerRadiusBottomLeft = rad,
cornerRadiusBottomRight = rad, ).encode(
x= alt.X('start', title = 'Period per person'),
x2= 'end',
y=alt.Y('position'),
color=alt.Color('gender'),
tooltip=['Responsible'],
column='Manager'
).resolve_scale(x = 'independent')
