Is there a way to make the distance or gap between certain intervals larger? For example, consider the code below:
data = {
'start': ['2023-01-01', '2023-02-01', '2023-03-01', '2023-04-01', '2023-05-01', '2023-06-01', '2023-07-01'],
'selection': ['year', 'year', 'month', 'year', 'year', 'year', 'month'],
'category': [1990, 1997, 'Jan', 2000, 1995, 2008, 'Feb']
}
df = pd.DataFrame(data)
fig = make_subplots(rows=1, cols=1, shared_xaxes=True)
fig1 = px.line(df, x='start', y="category", color='selection', facet_row="selection", line_shape="hv").data
for trace in fig1:
fig.add_trace(trace, 1, 1)
# Update axis
category_array = ['Jan', 'Feb', 'Mar', 'Apr']
category_array += [str(year) for year in range(1990, 2010)]
fig.update_yaxes(type='category', categoryarray=category_array)
fig.show()
This produces a plot like this:
Now, if I like to make the year
intervals part to take less space, and more for the month
part, say a 50/50 proportion, how can I achieve this? (I will need the subplot to make more rows)
This question is somewhat similar to this Is it possible to have a y-axis with uneven intervals/ticks, but have it evenly spaced? But the OP there suggested to use subplot to achieve that, however subplot will be used for another purpose (to plot multiple such dataframes).