calplot icon indicating copy to clipboard operation
calplot copied to clipboard

Image left shifted

Open KirbyJames opened this issue 3 years ago • 6 comments

Hi, Using your examples I've found that if you specify more than one year and a colorbar the output image is shifted to the left so that only half of the large year legend is visible.

all_days = pd.date_range('1/1/2019', periods=500, freq='D')
days = np.random.choice(all_days, 500)
events = pd.Series(np.random.randn(len(days)), index=days)
fig, axes = calplot.calplot(events, colorbar=True, cmap='YlGn')
fig.savefig('test.png')

image

KirbyJames avatar Feb 27 '21 13:02 KirbyJames

image

It seems to be proportional to number of years visualized.

xmichaelx avatar Mar 01 '21 15:03 xmichaelx

@KirbyJames removing plt.tight_layout() solves the issue for me

xmichaelx avatar Mar 01 '21 16:03 xmichaelx

Thanks @xmichaelx - it gives plenty of white space ;-) image

KirbyJames avatar Mar 01 '21 17:03 KirbyJames

I worked around this with fig.savefig("test.png", bbox_inches="tight").

carsonyl avatar Mar 03 '21 07:03 carsonyl

@carsonyl Briliant - this works for me both under Windows 10 and Raspbian. Many Thanks

KirbyJames avatar Mar 03 '21 09:03 KirbyJames

plt.tight_layout() can be turned off by passing tight_layout=False to calplot.calplot() in new calplot release 0.1.7.

calplot.calplot(events, tight_layout=False)

This issue is not present on my macOS set-up. Will investigate later.

tomkwok avatar Mar 03 '21 15:03 tomkwok