在linux下用matplotlib制作icon

# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.lines import Line2D

def icondm():
        fig1 = plt.figure()
        ax1 = fig1.add_subplot(111, aspect='equal')
        ax1.add_patch(
        patches.Rectangle(
           (0., 0.),   # (x,y)
           1.,          # width
           1.,          # height
           0.,
           color='lime',
           )
        )
        line1=[(0.1,0.1),(0.9,0.1)]
        (line1_xs, line1_ys) = zip(*line1)
        ax1.add_line(Line2D(line1_xs,line1_ys,linewidth=25,color='white'))
        plt.axis('off')
        plt.arrow(0.5,0.1,0.,0.8,#x,y,dx,dy
           width=0.1, color='white',
           head_width=0.4,head_length=0.4,
           length_includes_head=True
        )
        fig1.savefig('iot_dm.png', dpi=90, bbox_inches='tight')
        plt.show()
        return
def iconmd():
        fig1 = plt.figure()
        ax1 = fig1.add_subplot(111, aspect='equal')
        ax1.add_patch(
        patches.Rectangle(
           (0., 0.),   # (x,y)
           1.,          # width
           1.,          # height
           0.,
           color='dodgerblue',
           )
        )
        line1=[(0.1,0.1),(0.9,0.1)]
        (line1_xs, line1_ys) = zip(*line1)
        ax1.add_line(Line2D(line1_xs,line1_ys,linewidth=25,color='white'))
        plt.axis('off')
        plt.arrow(0.5,0.9,0.,-0.8,#x,y,dx,dy
           width=0.1, color='white',
           head_width=0.4,head_length=0.4,
           length_includes_head=True
        )
        fig1.savefig('iot_md.png', dpi=90, bbox_inches='tight')
        return
iconmd()
icondm()

在python3.6.8下运行,生成两个图标文件,然后用convert和pixcut调整一下(去掉白边、缩小到64x64):

pngs=`ls *.png`
for aa in $pngs;do
        echo $aa
        convert $aa $aa.ras
        pixcut $aa.ras $aa-cut.ras
        convert -resize 64x64 $aa-cut.ras $aa
done

图做出来是上面的样子,未缩小

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值