matplotlib quiver 键标签被剪掉 [英] matplotlib quiver key label getting cut
问题描述
复制文档中的示例时,与箭袋键关联的标签未显示.有什么想法吗?
感谢大家的回复.@X帮助我意识到区别在于使用 plot.show()
并保存 plt.savefig('plot')
后查看图.
将matplotlib.pyplot导入为plt将numpy导入为npX, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, .2))U = np.cos(X)V = np.sin(Y)fig1,ax1 = plt.subplots()ax1.set_title('带绘图宽度的箭头比例,而不是视图')Q = ax1.quiver(X, Y, U, V, units='width')qk = ax1.quiverkey(Q,0.9,0.9,2,r'$ 2 \ frac {m} {s} $',labelpos ='E',坐标=数字")
实际:
tight_layout似乎在压缩"我的密钥.
fig1, ax1 = plt.subplots()ax1.set_title('带绘图宽度的箭头比例,而不是视图')Q = ax1.quiver(X,Y,U,V,单位='宽度')qk = ax1.quiverkey(Q,0.9,0.9,2,r'$ 2 \ frac {m} {s} $',labelpos ='E',坐标=数字")plt.tight_layout()plt.show()
另一个例子:尝试在文档中使用简单的颤动示例为我切断了钥匙.
编辑 2:使用 coordinates='axes'
确实有助于了解密钥的去向,但它仍然为我切断了标签.
将matplotlib.pyplot导入为plt将numpy导入为npX, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, .2))U = np.cos(X)V = np.sin(Y)fig1,ax1 = plt.subplots()ax1.set_title('箭头随绘图宽度缩放,而不是视图')Q = ax1.quiver(X, Y, U, V, units='width')qk = ax1.quiverkey(Q,1.0,1.02,2,r'$ 2 \ frac {m} {s} $',labelpos ='E',坐标='轴')
操作系统:Windows
Python:3.8.6
基于Matplotlib的版本:3.3.2
Matplotlib 设置:rcparams 没有变化(见下文).
环境:Jupyter实验室带有postBuild脚本,但我认为没有关系.
plt.rcParamsRcParams({'_ internal.classic_mode':False,'agg.path.chunksize':0,'animation.avconv_args':[],'animation.avconv_path': 'avconv','animation.bitrate':-1,'animation.codec':'h264','animation.convert_args': [],'animation.convert_path': '转换','animation.embed_limit':20.0,'animation.ffmpeg_args':[],'animation.ffmpeg_path': 'ffmpeg','animation.frame_format':'png','animation.html': '无','animation.html_args': [],'animation.writer': 'ffmpeg','axes.autolimit_mode': '数据','axes.axisbelow':'line','axes.edgecolor':'黑色','axes.facecolor':'白色','axes.formatter.limits':[-5、6],'axes.formatter.min_exponent':0,'axes.formatter.offset_threshold': 4,'axes.formatter.use_locale':False,'axes.formatter.use_mathtext':错误,'axes.formatter.useoffset':是的,'axes.grid':错误,'axes.grid.axis':'both','axes.grid.which': '主要','axes.labelcolor': '黑色','axes.labelpad':4.0,'axes.labelsize':'medium','axes.labelweight': '正常','axes.linewidth':0.8,'axes.prop_cycle': cycler('color', ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f','#bcbd22','#17becf']),'axes.spines.bottom':是的,'axes.spines.left':是的,'axes.spines.right':是的,'axes.spines.top':是的,'axes.titlecolor': '自动','axes.titlelocation':'center','axes.titlepad': 6.0,'axes.titlesize': '大','axes.titleweight': '正常','axes.titley':无,'axes.unicode_minus':是的,'axes.xmargin':0.05,'axes.ymargin': 0.05,'axes3d.grid':是的,'后端':'module://ipykernel.pylab.backend_inline','backend_fallback':是的,'boxplot.bootstrap':无,'boxplot.boxprops.color': '黑色','boxplot.boxprops.linestyle': '-','boxplot.boxprops.linewidth':1.0,'boxplot.capprops.color': '黑色','boxplot.capprops.linestyle':'-','boxplot.capprops.linewidth':1.0,'boxplot.flierprops.color':'黑色','boxplot.flierprops.linestyle': '无','boxplot.flierprops.linewidth':1.0,'boxplot.flierprops.marker': 'o','boxplot.flierprops.markeredgecolor':'黑色','boxplot.flierprops.markeredgewidth':1.0,'boxplot.flierprops.markerfacecolor':'无','boxplot.flierprops.markersize':6.0,'boxplot.meanline':错误,'boxplot.meanprops.color': 'C2','boxplot.meanprops.linestyle': '--','boxplot.meanprops.linewidth':1.0,'boxplot.meanprops.marker':'^','boxplot.meanprops.markeredgecolor':'C2','boxplot.meanprops.markerfacecolor':'C2','boxplot.meanprops.markersize':6.0,'boxplot.medianprops.color':'C1','boxplot.medianprops.linestyle': '-','boxplot.medianprops.linewidth':1.0,'boxplot.notch':否,'boxplot.patchartist':错误,'boxplot.showbox':是的,'boxplot.showcaps':是的,'boxplot.showfliers':对,'boxplot.showmeans':否,'boxplot.vertical':真,'boxplot.whiskerprops.color':'黑色','boxplot.whiskerprops.linestyle': '-','boxplot.whiskerprops.linewidth':1.0,'boxplot.whiskers':1.5,'contour.corner_mask':是的,'contour.linewidth':无,'contour.negative_linestyle':'虚线','date.autoformatter.day':'%Y-%m-%d','date.autoformatter.hour': '%m-%d %H','date.autoformatter.microsecond':'%M:%S.%f','date.autoformatter.minute': '%d %H:%M','date.autoformatter.month':'%Y-%m','date.autoformatter.second': '%H:%M:%S','date.autoformatter.year': '%Y','date.epoch': '1970-01-01T00:00:00','docstring.hardcopy':错误,'errorbar.capsize':0.0,'figure.autolayout':否,'figure.constrained_layout.h_pad':0.04167,'figure.constrained_layout.hspace':0.02,'figure.constrained_layout.use':错误,'figure.constrained_layout.w_pad':0.04167,'figure.constrained_layout.wspace':0.02,'figure.dpi':72.0,'figure.edgecolor': (1, 1, 1, 0),'figure.facecolor': (1, 1, 1, 0),'figure.figsize': [6.0, 4.0],'figure.frameon':是的,'figure.max_open_warning':20,'figure.raise_window':是的,'figure.subplot.bottom':0.125,'figure.subplot.hspace':0.2,'figure.subplot.left':0.125,'figure.subplot.right':0.9,'figure.subplot.top':0.88,'figure.subplot.wspace':0.2,'figure.titlesize':'大','figure.titleweight':'普通','font.cursive': ['Apple Chancery','纺织品','Zapf Chancery','沙','脚本 MT','Felipa','草书'],'font.family': ['sans-serif'],'font.fantasy': ['Comic Neue','Comic Sans MS','芝加哥','木炭','影响西方','幽默Sans','xkcd','幻想'],'font.monospace':['DejaVu Sans Mono',"Bitstream Vera Sans Mono",'现代计算机打字机','安代尔单声道','Nimbus Mono L','快递新','信使','固定的','终端','等宽'],'font.sans-serif':['DejaVu Sans','比特流维拉Sans','计算机现代无衬线','Lucida Grande','维尔达纳','日内瓦','清醒','阿里亚尔','Helvetica',《先锋派》,'无衬线字体'],'font.serif': ['DejaVu Serif','比特流维拉衬线',计算机现代罗马书",《新世纪教科书》,世纪教科书L",《乌托邦》,"ITC Bookman",'Bookman','Nimbus Roman No9 L','英语字体格式一种',《时代》,'帕拉蒂诺','宪章','serif'],'字体大小':10.0,'font.stretch':'普通','font.style':'普通','font.variant': '正常','font.weight':'普通','grid.alpha': 1.0,'grid.color': '#b0b0b0','grid.linestyle': '-','grid.linewidth': 0.8,'hatch.color': '黑色','hatch.linewidth':1.0,'hist.bins':10,'image.aspect': '相等','image.cmap': 'viridis','image.composite_image':是的,'image.interpolation': '抗锯齿','image.lut':256,'image.origin':'upper','image.resample':是的,互动":是的,'keymap.all_axes': ['a'],'keymap.back':['left','c','backspace','MouseButton.BACK'],'keymap.copy': ['ctrl+c', 'cmd+c'],'keymap.forward': ['right', 'v', 'MouseButton.FORWARD'],'keymap.fullscreen': ['f', 'ctrl+f'],'keymap.grid':['g'],'keymap.grid_minor':['G'],'keymap.help': ['f1'],'keymap.home': ['h', 'r', 'home'],'keymap.pan':['p'],'keymap.quit':['ctrl + w','cmd + w','q'],'keymap.quit_all':[],'keymap.save':['s','ctrl + s'],'keymap.xscale': ['k', 'L'],'keymap.yscale':['l'],'keymap.zoom': ['o'],'legend.borderaxespad':0.5,'legend.borderpad':0.4,'legend.columnspacing':2.0,'legend.edgecolor': '0.8','legend.facecolor': '继承','legend.fancybox':是的,'legend.fontsize': '中等','legend.framealpha': 0.8,'legend.frameon':是的,'legend.handleheight':0.7,'legend.handlelength':2.0,'legend.handletextpad':0.8,'legend.labelspacing':0.5,'legend.loc': '最好的','legend.markerscale':1.0,'legend.numpoints':1,'legend.scatterpoints':1,'legend.shadow':错误,'legend.title_fontsize':无,'lines.antialiased':是的,'lines.color':'C0','lines.dash_capstyle':'对接','lines.dash_joinstyle': '圆形','lines.dashdot_pattern': [6.4, 1.6, 1.0, 1.6],'lines.dashed_pattern': [3.7, 1.6],'lines.dotted_pattern': [1.0, 1.65],'lines.linestyle':'-','lines.linewidth':1.5,'lines.marker':'无','lines.markeredgecolor': '自动','lines.markeredgewidth':1.0,'lines.markerfacecolor': '自动','lines.markersize':6.0,'lines.scale_dashes':真,'lines.solid_capstyle':'投影中','lines.solid_joinstyle':'回合','markers.fillstyle':'完整','mathtext.bf': 'sans:bold','mathtext.cal':'草书','mathtext.default': '它','mathtext.fallback':'cm','mathtext.fallback_to_cm':无,'mathtext.fontset': 'dejavusans','mathtext.it':'sans:italic','mathtext.rm':'sans','mathtext.sf':'sans','mathtext.tt':'等宽线','mpl_toolkits.legacy_colorbar':是的,'patch.antialiased':是的,'patch.edgecolor':'黑色','patch.facecolor':'C0','patch.force_edgecolor':错误,'patch.linewidth': 1.0,'path.effects': [],'path.simplify':对,'path.simplify_threshold':0.111111111111,'path.sketch':无,'path.snap':是的,'pcolor.shading':'flat','pdf.compression':6,'pdf.fonttype': 3,'pdf.inheritcolor':错误,'pdf.use14corefonts':错误,'pgf.preamble': '','pgf.rcfonts':是的,'pgf.texsystem': 'xelatex','polaraxes.grid':是的,'ps.distiller.res': 6000,'ps.fonttype':3,'ps.papersize':'letter','ps.useafm':错误,'ps.usedistiller':无,'savefig.bbox':无,'savefig.directory': '~','savefig.dpi': '数字','savefig.edgecolor':'自动','savefig.facecolor': '自动','savefig.format': 'png','savefig.jpeg_quality':95,'savefig.orientation': '肖像','savefig.pad_inches':0.1,'savefig.transparent':否,'scatter.edgecolors':'面部','scatter.marker': 'o','svg.fonttype': '路径','svg.hashsalt':无,'svg.image_inline':是的,'text.antialiased':真,'text.color': '黑色','text.hinting':'force_autohint','text.hinting_factor':8'text.kerning_factor':0,'text.latex.preamble': '','text.latex.preview':否,'text.usetex':否,'时区': 'UTC','tk.window_focus':错误,'toolbar':'toolbar2','webagg.address': '127.0.0.1','webagg.open_in_browser':是的,'webagg.port':8988,'webagg.port_retries': 50,'xaxis.labellocation':'中心','xtick.alignment': '中心','xtick.bottom':是的,'xtick.color': '黑色','xtick.direction':'输出','xtick.labelbottom':是的,'xtick.labelsize': '中等','xtick.labeltop':否,'xtick.major.bottom':是的,'xtick.major.pad':3.5,'xtick.major.size': 3.5,'xtick.major.top':是的,'xtick.major.width':0.8,'xtick.minor.bottom':是的,'xtick.minor.pad':3.4,'xtick.minor.size': 2.0,'xtick.minor.top':是的,'xtick.minor.visible':错误,'xtick.minor.width':0.6,'xtick.top':否,'yaxis.labellocation':'center','ytick.alignment':'center_baseline','ytick.color':'黑色','ytick.direction':'out','ytick.labelleft':是的,'ytick.labelright':错误,'ytick.labelsize':'medium','ytick.left':是的,'ytick.major.left':是的,'ytick.major.pad': 3.5,'ytick.major.right':对,'ytick.major.size':3.5,'ytick.major.width':0.8,'ytick.minor.left':是的,'ytick.minor.pad':3.4,'ytick.minor.right':是的,'ytick.minor.size':2.0,ytick.minor.visible":错误,'ytick.minor.width':0.6,'ytick.right': 错误})
我的猜测是,您的后端正在以某种方式改变您的图形尺寸,并移动了颤动键.为什么要在图形坐标中使用它?建议您将其相对于轴定位:
将matplotlib.pyplot导入为plt将numpy导入为npX, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, .2))U = np.cos(X)V = np.sin(Y)fig1,ax1 = plt.subplots()ax1.set_title('带绘图宽度的箭头比例,而不是视图')Q = ax1.quiver(X, Y, U, V, units='width')qk = ax1.quiverkey(Q, 1.0, 1.02, 2, r'$2 \frac{m}{s}$', labelpos='E',坐标='轴')plt.show()
When copying the example in the docs the label associated with the quiver key is not showing up. Any thoughts?
Edit: Thanks all for your responses. @X helped me realize the difference comes from using plot.show()
and viewing the plot after saving plt.savefig('plot')
.
Expected:
import matplotlib.pyplot as plt
import numpy as np
X, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, .2))
U = np.cos(X)
V = np.sin(Y)
fig1, ax1 = plt.subplots()
ax1.set_title('Arrows scale with plot width, not view')
Q = ax1.quiver(X, Y, U, V, units='width')
qk = ax1.quiverkey(Q, 0.9, 0.9, 2, r'$2 \frac{m}{s}$', labelpos='E',
coordinates='figure')
Actual:
Edit: tight_layout seems to 'squish' my key.
fig1, ax1 = plt.subplots()
ax1.set_title('Arrows scale with plot width, not view')
Q = ax1.quiver(X, Y, U, V, units='width')
qk = ax1.quiverkey(Q, 0.9, 0.9, 2, r'$2 \frac{m}{s}$', labelpos='E',
coordinates='figure')
plt.tight_layout()
plt.show()
Edit: Another example: it seems trying the simple quiver example in the docs cuts off the key for me.
https://matplotlib.org/3.3.2/gallery/images_contours_and_fields/quiver_simple_demo.html
import matplotlib.pyplot as plt
import numpy as np
X = np.arange(-10, 10, 1)
Y = np.arange(-10, 10, 1)
U, V = np.meshgrid(X, Y)
fig, ax = plt.subplots()
q = ax.quiver(X, Y, U, V)
ax.quiverkey(q, X=0.3, Y=1.1, U=10,
label='Quiver key, length = 10', labelpos='E')
plt.show()
Edit 2: Using coordinates='axes'
does help a bit to know where the key is going but it still cuts off the label for me.
import matplotlib.pyplot as plt
import numpy as np
X, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, .2))
U = np.cos(X)
V = np.sin(Y)
fig1, ax1 = plt.subplots()
ax1.set_title('Arrows scale with plot width, not view')
Q = ax1.quiver(X, Y, U, V, units='width')
qk = ax1.quiverkey(Q, 1.0, 1.02, 2, r'$2 \frac{m}{s}$', labelpos='E',
coordinates='axes')
OS: Windows
Python: 3.8.6
Matplotlib-base: 3.3.2
Matplotlib settings: No changes to rcparams (see below).
Environment: Jupyter lab with a postBuild script but I don't think is related.
plt.rcParams
RcParams({'_internal.classic_mode': False,
'agg.path.chunksize': 0,
'animation.avconv_args': [],
'animation.avconv_path': 'avconv',
'animation.bitrate': -1,
'animation.codec': 'h264',
'animation.convert_args': [],
'animation.convert_path': 'convert',
'animation.embed_limit': 20.0,
'animation.ffmpeg_args': [],
'animation.ffmpeg_path': 'ffmpeg',
'animation.frame_format': 'png',
'animation.html': 'none',
'animation.html_args': [],
'animation.writer': 'ffmpeg',
'axes.autolimit_mode': 'data',
'axes.axisbelow': 'line',
'axes.edgecolor': 'black',
'axes.facecolor': 'white',
'axes.formatter.limits': [-5, 6],
'axes.formatter.min_exponent': 0,
'axes.formatter.offset_threshold': 4,
'axes.formatter.use_locale': False,
'axes.formatter.use_mathtext': False,
'axes.formatter.useoffset': True,
'axes.grid': False,
'axes.grid.axis': 'both',
'axes.grid.which': 'major',
'axes.labelcolor': 'black',
'axes.labelpad': 4.0,
'axes.labelsize': 'medium',
'axes.labelweight': 'normal',
'axes.linewidth': 0.8,
'axes.prop_cycle': cycler('color', ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']),
'axes.spines.bottom': True,
'axes.spines.left': True,
'axes.spines.right': True,
'axes.spines.top': True,
'axes.titlecolor': 'auto',
'axes.titlelocation': 'center',
'axes.titlepad': 6.0,
'axes.titlesize': 'large',
'axes.titleweight': 'normal',
'axes.titley': None,
'axes.unicode_minus': True,
'axes.xmargin': 0.05,
'axes.ymargin': 0.05,
'axes3d.grid': True,
'backend': 'module://ipykernel.pylab.backend_inline',
'backend_fallback': True,
'boxplot.bootstrap': None,
'boxplot.boxprops.color': 'black',
'boxplot.boxprops.linestyle': '-',
'boxplot.boxprops.linewidth': 1.0,
'boxplot.capprops.color': 'black',
'boxplot.capprops.linestyle': '-',
'boxplot.capprops.linewidth': 1.0,
'boxplot.flierprops.color': 'black',
'boxplot.flierprops.linestyle': 'none',
'boxplot.flierprops.linewidth': 1.0,
'boxplot.flierprops.marker': 'o',
'boxplot.flierprops.markeredgecolor': 'black',
'boxplot.flierprops.markeredgewidth': 1.0,
'boxplot.flierprops.markerfacecolor': 'none',
'boxplot.flierprops.markersize': 6.0,
'boxplot.meanline': False,
'boxplot.meanprops.color': 'C2',
'boxplot.meanprops.linestyle': '--',
'boxplot.meanprops.linewidth': 1.0,
'boxplot.meanprops.marker': '^',
'boxplot.meanprops.markeredgecolor': 'C2',
'boxplot.meanprops.markerfacecolor': 'C2',
'boxplot.meanprops.markersize': 6.0,
'boxplot.medianprops.color': 'C1',
'boxplot.medianprops.linestyle': '-',
'boxplot.medianprops.linewidth': 1.0,
'boxplot.notch': False,
'boxplot.patchartist': False,
'boxplot.showbox': True,
'boxplot.showcaps': True,
'boxplot.showfliers': True,
'boxplot.showmeans': False,
'boxplot.vertical': True,
'boxplot.whiskerprops.color': 'black',
'boxplot.whiskerprops.linestyle': '-',
'boxplot.whiskerprops.linewidth': 1.0,
'boxplot.whiskers': 1.5,
'contour.corner_mask': True,
'contour.linewidth': None,
'contour.negative_linestyle': 'dashed',
'date.autoformatter.day': '%Y-%m-%d',
'date.autoformatter.hour': '%m-%d %H',
'date.autoformatter.microsecond': '%M:%S.%f',
'date.autoformatter.minute': '%d %H:%M',
'date.autoformatter.month': '%Y-%m',
'date.autoformatter.second': '%H:%M:%S',
'date.autoformatter.year': '%Y',
'date.epoch': '1970-01-01T00:00:00',
'docstring.hardcopy': False,
'errorbar.capsize': 0.0,
'figure.autolayout': False,
'figure.constrained_layout.h_pad': 0.04167,
'figure.constrained_layout.hspace': 0.02,
'figure.constrained_layout.use': False,
'figure.constrained_layout.w_pad': 0.04167,
'figure.constrained_layout.wspace': 0.02,
'figure.dpi': 72.0,
'figure.edgecolor': (1, 1, 1, 0),
'figure.facecolor': (1, 1, 1, 0),
'figure.figsize': [6.0, 4.0],
'figure.frameon': True,
'figure.max_open_warning': 20,
'figure.raise_window': True,
'figure.subplot.bottom': 0.125,
'figure.subplot.hspace': 0.2,
'figure.subplot.left': 0.125,
'figure.subplot.right': 0.9,
'figure.subplot.top': 0.88,
'figure.subplot.wspace': 0.2,
'figure.titlesize': 'large',
'figure.titleweight': 'normal',
'font.cursive': ['Apple Chancery',
'Textile',
'Zapf Chancery',
'Sand',
'Script MT',
'Felipa',
'cursive'],
'font.family': ['sans-serif'],
'font.fantasy': ['Comic Neue',
'Comic Sans MS',
'Chicago',
'Charcoal',
'ImpactWestern',
'Humor Sans',
'xkcd',
'fantasy'],
'font.monospace': ['DejaVu Sans Mono',
'Bitstream Vera Sans Mono',
'Computer Modern Typewriter',
'Andale Mono',
'Nimbus Mono L',
'Courier New',
'Courier',
'Fixed',
'Terminal',
'monospace'],
'font.sans-serif': ['DejaVu Sans',
'Bitstream Vera Sans',
'Computer Modern Sans Serif',
'Lucida Grande',
'Verdana',
'Geneva',
'Lucid',
'Arial',
'Helvetica',
'Avant Garde',
'sans-serif'],
'font.serif': ['DejaVu Serif',
'Bitstream Vera Serif',
'Computer Modern Roman',
'New Century Schoolbook',
'Century Schoolbook L',
'Utopia',
'ITC Bookman',
'Bookman',
'Nimbus Roman No9 L',
'Times New Roman',
'Times',
'Palatino',
'Charter',
'serif'],
'font.size': 10.0,
'font.stretch': 'normal',
'font.style': 'normal',
'font.variant': 'normal',
'font.weight': 'normal',
'grid.alpha': 1.0,
'grid.color': '#b0b0b0',
'grid.linestyle': '-',
'grid.linewidth': 0.8,
'hatch.color': 'black',
'hatch.linewidth': 1.0,
'hist.bins': 10,
'image.aspect': 'equal',
'image.cmap': 'viridis',
'image.composite_image': True,
'image.interpolation': 'antialiased',
'image.lut': 256,
'image.origin': 'upper',
'image.resample': True,
'interactive': True,
'keymap.all_axes': ['a'],
'keymap.back': ['left', 'c', 'backspace', 'MouseButton.BACK'],
'keymap.copy': ['ctrl+c', 'cmd+c'],
'keymap.forward': ['right', 'v', 'MouseButton.FORWARD'],
'keymap.fullscreen': ['f', 'ctrl+f'],
'keymap.grid': ['g'],
'keymap.grid_minor': ['G'],
'keymap.help': ['f1'],
'keymap.home': ['h', 'r', 'home'],
'keymap.pan': ['p'],
'keymap.quit': ['ctrl+w', 'cmd+w', 'q'],
'keymap.quit_all': [],
'keymap.save': ['s', 'ctrl+s'],
'keymap.xscale': ['k', 'L'],
'keymap.yscale': ['l'],
'keymap.zoom': ['o'],
'legend.borderaxespad': 0.5,
'legend.borderpad': 0.4,
'legend.columnspacing': 2.0,
'legend.edgecolor': '0.8',
'legend.facecolor': 'inherit',
'legend.fancybox': True,
'legend.fontsize': 'medium',
'legend.framealpha': 0.8,
'legend.frameon': True,
'legend.handleheight': 0.7,
'legend.handlelength': 2.0,
'legend.handletextpad': 0.8,
'legend.labelspacing': 0.5,
'legend.loc': 'best',
'legend.markerscale': 1.0,
'legend.numpoints': 1,
'legend.scatterpoints': 1,
'legend.shadow': False,
'legend.title_fontsize': None,
'lines.antialiased': True,
'lines.color': 'C0',
'lines.dash_capstyle': 'butt',
'lines.dash_joinstyle': 'round',
'lines.dashdot_pattern': [6.4, 1.6, 1.0, 1.6],
'lines.dashed_pattern': [3.7, 1.6],
'lines.dotted_pattern': [1.0, 1.65],
'lines.linestyle': '-',
'lines.linewidth': 1.5,
'lines.marker': 'None',
'lines.markeredgecolor': 'auto',
'lines.markeredgewidth': 1.0,
'lines.markerfacecolor': 'auto',
'lines.markersize': 6.0,
'lines.scale_dashes': True,
'lines.solid_capstyle': 'projecting',
'lines.solid_joinstyle': 'round',
'markers.fillstyle': 'full',
'mathtext.bf': 'sans:bold',
'mathtext.cal': 'cursive',
'mathtext.default': 'it',
'mathtext.fallback': 'cm',
'mathtext.fallback_to_cm': None,
'mathtext.fontset': 'dejavusans',
'mathtext.it': 'sans:italic',
'mathtext.rm': 'sans',
'mathtext.sf': 'sans',
'mathtext.tt': 'monospace',
'mpl_toolkits.legacy_colorbar': True,
'patch.antialiased': True,
'patch.edgecolor': 'black',
'patch.facecolor': 'C0',
'patch.force_edgecolor': False,
'patch.linewidth': 1.0,
'path.effects': [],
'path.simplify': True,
'path.simplify_threshold': 0.111111111111,
'path.sketch': None,
'path.snap': True,
'pcolor.shading': 'flat',
'pdf.compression': 6,
'pdf.fonttype': 3,
'pdf.inheritcolor': False,
'pdf.use14corefonts': False,
'pgf.preamble': '',
'pgf.rcfonts': True,
'pgf.texsystem': 'xelatex',
'polaraxes.grid': True,
'ps.distiller.res': 6000,
'ps.fonttype': 3,
'ps.papersize': 'letter',
'ps.useafm': False,
'ps.usedistiller': None,
'savefig.bbox': None,
'savefig.directory': '~',
'savefig.dpi': 'figure',
'savefig.edgecolor': 'auto',
'savefig.facecolor': 'auto',
'savefig.format': 'png',
'savefig.jpeg_quality': 95,
'savefig.orientation': 'portrait',
'savefig.pad_inches': 0.1,
'savefig.transparent': False,
'scatter.edgecolors': 'face',
'scatter.marker': 'o',
'svg.fonttype': 'path',
'svg.hashsalt': None,
'svg.image_inline': True,
'text.antialiased': True,
'text.color': 'black',
'text.hinting': 'force_autohint',
'text.hinting_factor': 8,
'text.kerning_factor': 0,
'text.latex.preamble': '',
'text.latex.preview': False,
'text.usetex': False,
'timezone': 'UTC',
'tk.window_focus': False,
'toolbar': 'toolbar2',
'webagg.address': '127.0.0.1',
'webagg.open_in_browser': True,
'webagg.port': 8988,
'webagg.port_retries': 50,
'xaxis.labellocation': 'center',
'xtick.alignment': 'center',
'xtick.bottom': True,
'xtick.color': 'black',
'xtick.direction': 'out',
'xtick.labelbottom': True,
'xtick.labelsize': 'medium',
'xtick.labeltop': False,
'xtick.major.bottom': True,
'xtick.major.pad': 3.5,
'xtick.major.size': 3.5,
'xtick.major.top': True,
'xtick.major.width': 0.8,
'xtick.minor.bottom': True,
'xtick.minor.pad': 3.4,
'xtick.minor.size': 2.0,
'xtick.minor.top': True,
'xtick.minor.visible': False,
'xtick.minor.width': 0.6,
'xtick.top': False,
'yaxis.labellocation': 'center',
'ytick.alignment': 'center_baseline',
'ytick.color': 'black',
'ytick.direction': 'out',
'ytick.labelleft': True,
'ytick.labelright': False,
'ytick.labelsize': 'medium',
'ytick.left': True,
'ytick.major.left': True,
'ytick.major.pad': 3.5,
'ytick.major.right': True,
'ytick.major.size': 3.5,
'ytick.major.width': 0.8,
'ytick.minor.left': True,
'ytick.minor.pad': 3.4,
'ytick.minor.right': True,
'ytick.minor.size': 2.0,
'ytick.minor.visible': False,
'ytick.minor.width': 0.6,
'ytick.right': False})
My guess is that somehow your backend is changing the figure size on you and that moves the quiver key. Why do you want it in figure co-ordinates? Suggest you position it relative to the axes:
import matplotlib.pyplot as plt
import numpy as np
X, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, .2))
U = np.cos(X)
V = np.sin(Y)
fig1, ax1 = plt.subplots()
ax1.set_title('Arrows scale with plot width, not view')
Q = ax1.quiver(X, Y, U, V, units='width')
qk = ax1.quiverkey(Q, 1.0, 1.02, 2, r'$2 \frac{m}{s}$', labelpos='E',
coordinates='axes')
plt.show()
这篇关于matplotlib quiver 键标签被剪掉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!