Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Matplotlib中显示EAN-13条形码_Python_Matplotlib_Plot_Barcode - Fatal编程技术网

Python 在Matplotlib中显示EAN-13条形码

Python 在Matplotlib中显示EAN-13条形码,python,matplotlib,plot,barcode,Python,Matplotlib,Plot,Barcode,我想在Matplotlib中显示EAN条形码。我尝试使用包作为条形码,但这只会打印到.svg和.png,这对我的应用程序来说非常不方便。如何放置EAN条形码,如以下示例所示: 绘图中的条形码: 我还附上了用于绘制图像的代码,因为它现在是: # Plot opzetten # Create figure and axes fig,ax = plt.subplots(figsize=(5.5,2.5)) #plt.figure(figsize=(5.5,3)) # Header plotten

我想在Matplotlib中显示EAN条形码。我尝试使用包作为条形码,但这只会打印到.svg和.png,这对我的应用程序来说非常不方便。如何放置EAN条形码,如以下示例所示:

绘图中的条形码:

我还附上了用于绘制图像的代码,因为它现在是:

# Plot opzetten
# Create figure and axes
fig,ax = plt.subplots(figsize=(5.5,2.5))
#plt.figure(figsize=(5.5,3))

# Header plotten
font_dict = {'family':'sans-serif',
             'color':'white',
             'horizontalalignment':'center',
             'verticalalignment':'center',
             'weight':'normal',
             'size': 14
             }

ax.text(0.5,(0.94-0.005),Header,fontdict=font_dict)

# Artikelnaam plotten
font_dict = {'family':'sans-serif',
             'color':'black',
             'horizontalalignment':'center',
             'verticalalignment':'center',
             'weight':'normal',
             'size': 14
             }

ax.text(0.5,(0.80-0.005),Artikelnaam,fontdict=font_dict)

# Prijs_header plotten
font_dict = {'family':'sans-serif',
             'color':'white',
             'horizontalalignment':'left',
             'verticalalignment':'center',
             'weight':'heavy',
             'size': 14
             }

ax.text(0.58+.02,(0.31-0.005),Prijs_header,fontdict=font_dict)

# Prijs plotten
font_dict = {'family':'sans-serif',
             'color':'black',
             'horizontalalignment':'right',
             'verticalalignment':'center',
             'weight':'bold',
             'size': 22.5
             }

ax.text(1.00-.02,(0.125-0.005),'€' + str(round(Decimal(Prijs),2)),fontdict=font_dict)

# Artikelnummer plotten
font_dict = {'family':'sans-serif',
             'color':'black',
             'horizontalalignment':'left',
             'verticalalignment':'bottom',
             'weight':'normal',
             'size': 14
             }

ax.text(0+0.02,0+0.02,Artikelnummer,fontdict=font_dict)

# Patches
Header_patch = patches.Rectangle((0,.88),1,.12,linewidth=1,edgecolor='black',facecolor='black')
Artikelnaam_patch = patches.Rectangle((0,.72),1,.16,linewidth=1,edgecolor='black',facecolor='none')
EAN_patch = patches.Rectangle((0,.37),1,.35,linewidth=1,edgecolor='black',facecolor='none')
Artikelnummer_patch = patches.Rectangle((0,0),.58,.37,linewidth=1,edgecolor='black',facecolor='none')
Prijs_header_patch = patches.Rectangle((0.58,.25),.42,.12,linewidth=1,edgecolor='black',facecolor='black')


# Patches plotten
ax.add_patch(Header_patch)
ax.add_patch(Artikelnaam_patch)
ax.add_patch(EAN_patch)
ax.add_patch(Artikelnummer_patch)
ax.add_patch(Prijs_header_patch)

plt.gca().axes.get_yaxis().set_visible(False)
plt.gca().axes.get_xaxis().set_visible(False)

plt.show()

fig.savefig("Sticker_1.pdf", bbox_inches='tight')
matplotlib页面上有一个。你介意告诉我这在多大程度上不起作用吗?实施它有什么问题吗?