python - Matplotlib:创建与父轴不同的脊椎的 zoomed_inset_axis
问题描述
我有一个带有 zoomed_inset_axis 对象的图,如 https://matplotlib.org/3.1.1/_images/sphx_glr_inset_locator_demo2_001.png所示
现在我希望我的父轴对象以某种方式被指定,所以右脊椎不可见。但是,如果我这样做,我的放大插图也会以相同的方式进行,这是我不想要的。我认为发生这种情况是因为它以轴对象为父对象。
有什么办法可以改变吗?基本上我想要一个被“正常”框包围的被诅咒的父对象和一个放大的插图。
我试过seabon.despine(fig=fig, ax=ax)
了,但这也让我放大了对象。我也试过ax.spines['right'].set_visible=False
了,但这也鄙视我的缩放对象
fig, ax = plt.subplots(1,1)
axins = zoomed_inset_axes(ax, 7, loc=4)
seaborn.despine(fig=fig,ax=ax, offset=10)
解决方案
以下两项均按预期工作:
海伯恩的绝望
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
import seaborn as sns
fig, ax = plt.subplots(1,1)
axins = zoomed_inset_axes(ax, .5, loc=4)
sns.despine(ax=ax, offset=10)
plt.show()
matplotlib 的脊椎可见性
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
fig, ax = plt.subplots(1,1)
axins = zoomed_inset_axes(ax, .5, loc=4)
ax.spines['right'].set_visible(False)
plt.show()
推荐阅读
- google-speech-api - API Google Speech to Text - mp3 文件
- php - 在 Woocommerce 中仅为特定自定义字段值启用免费送货方式
- java - ISBN 检查器 - 无循环
- php - 如何在php中按月添加和获取销售额?
- vb.net - 将美分转换为给定的变化量
- c# - 如何访问使用 UriKind.Relative 定义的 Uri 的属性
- android - Android Retrofit 无法解析数据
- python - 删除python中包含相同值的行
- mysql - 根据 Hive 中另一个表中的时间戳在表中查找记录
- javascript - 如果我想将 React 组件的函数作为属性传递下去,那么包装它的意义何在?