简体   繁体   中英

How to change dimension of Seaborn relplot in Jupyter notebook

Much kudos to @mozway for helping me realise a pet project that I've been playing with. I am now looking to determine which parameter to tweak the output from chart.

You can see previous queries here:

How to create a multiindex chart in Pandas that combines categories and numericals

And why all praise to @mozway for helping me visualise the data.

I had to tweak his/her approach only because I'm a little rusty on Pandas, but essentially the same.

df2 = df.T.reset_index().melt(id_vars="week of year")

Which produced this...

    week of year    variable    value
0   1               Monday      22.8
1   2               Monday      0.0
2   3               Monday      22.8
3   1               Tuesday     7.6

...And so on

Then used Mozway's approach to plotting (answer here: How to turn dataframe with categorical rows and numerical columns into coherent chart (sparkline like) )

sns.relplot(data=piv6,
            y='value', x='variable',
            kind='line', row='week of year',
            height=1, aspect=10)

Which produced this:

在此处输入图像描述

Pretty much spot-on. And this is my fault, but I'd like to increase the vertical dimension of the plot so I can better understand the change over time.

You are using seaborn to generate those graphs, so the best thing you can do is to add:

sns.set(rc={'figure.figsize':(14,10)})

If you are using plotlib to generate those graph, then:

fig = matplotlib.pyplot.gcf() 
fig.set_size_inches(18.5, 10.5)

You can change the figure size as you would like.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM