【发布时间】:2016-07-08 21:44:46
【问题描述】:
目前,我绘制的图都是透明的,如下图所示,这使得它可以区分缩放部分和原始部分。
另外就是放大部分的位置,“loc”关键字只有1,...9,9个选项,我可以指定我喜欢的位置吗,比如坐标?
axins = zoomed_inset_axes(ax, 3, loc=5) # zoom = 6
我写了一个简单的代码你的修改目的。
from pylab import *
import re
rc('font',family='Arial')
matplotlib.rc('legend', fontsize=24)
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid1.inset_locator import mark_inset
font = {'family' : 'Arial',
'weight' : 'normal',
'size' : 24}
fig = figure(figsize=(8,8))
fig.set_alpha(0.0)
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
x=[0,1]
y=[0,1]
plot(x,y)
axins = zoomed_inset_axes(ax, 3, loc=5) # zoom = 6
axins.plot(x,y)
# sub region of the original image
x1, x2, y1, y2 = 0.3, 0.4, 0.3,0.4
axins.set_xlim(x1, x2)
axins.set_ylim(y1, y2)
plt.xticks(visible=False)
plt.yticks(visible=False)
# draw a bbox of the region of the inset axes in the parent axes and
# connecting lines between the bbox and the inset axes area
mark_inset(ax, axins, loc1=2, loc2=3, fc="none", ec="0.5")
plt.draw()
plt.show()
fig.savefig('1.png', transparent=True)
【问题讨论】:
-
如果你能给出一个最小的独立示例供我们研究,回答这个问题会容易得多。
-
感谢,添加示例代码^^
标签: python matplotlib zooming transparent