twinx

Define aspect ratio when using twinx in new version of matplotlib

狂风中的少年 提交于 2021-01-05 10:57:05
问题 Current version of matplotlib do not allow box-forced anymore, how should I do the same thing as the answer? I am using matplotlib 3.1.0. After I ploted another set of data on the same plot with twinx() function, I want to change the aspect ratio of the actual plot area to 1. Normally I do this and it works for non-twinx axis ratio = 1 xleft, xright = ax.get_xlim() ybottom, ytop = ax.get_ylim() ax.set_aspect(abs((xright - xleft) / (ybottom - ytop)) * ratio) For twinx axis, the above code do