简体   繁体   English

如何更新 matplotlib 中插入轴的位置

[英]How to update positions of inset axes in matplotlib

set_position() seems not to work for inset axes in matploltib, see code below: set_position()似乎不适用于 matploltib 中的插入轴,请参见下面的代码:

import matplotlib.pyplot as plt

fig, ax = plt.subplots(1, 1, figsize=(7.2, 7.2))
# make inset axes
axin = ax.inset_axes([0.1, 0.1, 0.2, 0.2])
# update position, NOT working
axin.set_position([0.2, 0.2, 0.2, 0.2])

在此处输入图像描述

Is there any way to update position of inset axes?有没有办法更新插入轴的 position?

Here's a great answer .这是一个很好的答案 I saw this and modified your code.我看到了这个并修改了你的代码。 I don't have enough knowledge to explain this so please refer to his answer.我没有足够的知识来解释这一点,所以请参考他的回答。

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import InsetPosition

fig, ax = plt.subplots(1, 1, figsize=(7.2, 7.2))
axin = ax.inset_axes([0.1, 0.1, 0.2, 0.2])

ip = InsetPosition(ax,[0.2, 0.2, 0.2, 0.2])
axin.set_axes_locator(ip)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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