fix legend calc_dims order problem