• 《Python数据可视化之matplotlib实践》 源码 第四篇 扩展 第十一章


    图  11.2 

     

    import matplotlib.pyplot as plt
    import matplotlib as mpl
    import numpy as np
    
    
    plt.axes([0.1, 0.1, 0.8, 0.8], frameon=True, facecolor="y", aspect="equal")
    plt.plot(2+np.arange(3), [0, 1, 0])
    plt.title("Line Chart")
    
    
    plt.text(2.25, 0.8, "FONT")
    
    
    plt.show()
    View Code

    ==================================

    图  11.3 

     

    import matplotlib.pyplot as plt
    import numpy as np
    
    
    plt.rcParams["lines.linewidth"]=8.0
    plt.rcParams["lines.linestyle"]="--"
    
    
    plt.rcParams["font.family"]="serif"
    plt.rcParams["font.serif"]="New Century Schoolbook"  ###
    plt.rcParams["font.style"]="normal"
    plt.rcParams["font.variant"]="small-caps"
    plt.rcParams["font.weight"]="black"
    plt.rcParams["font.size"]=12.0
    
    
    plt.rcParams["text.color"]="blue"
    
    
    plt.axes([0.1, 0.1, 0.8, 0.8], frameon=True, facecolor="y", aspect="equal")
    plt.plot(2+np.arange(3), [0, 1, 0])
    plt.title("Line Chart")
    
    
    plt.text(2.25, 0.8, "FONT")
    
    
    plt.show()
    View Code

    ==================================

    图  11.4 

     

    import matplotlib.pyplot as plt
    import numpy as np
    
    
    plt.axes([0.1, 0.1, 0.8, 0.8], frameon=True, facecolor="y", aspect="equal")
    
    
    plt.plot(2+np.arange(3), [0, 1, 0], linewidth=8.0, linestyle="--")
    plt.title("Line Chart", color="red", family="New Century Schoolbook", 
              style="normal", variant="small-caps", weight="black", size=18) ###
    
    
    plt.text(2.25, 0.8, "FONT", color="blue", fontdict={"family":"New Century Schoolbook", 
              "style":"normal", "variant":"small-caps", "weight":"black", "size":28}) ###
    
    
    plt.show()
    View Code

    ==================================

    图  11.5

     

    import matplotlib.pyplot as plt
    
    
    fig=plt.figure()
    ax=fig.add_subplot(111)
    
    
    pi=[0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1]
    
    
    
    
    families=["serif", "sans-serif", "fantasy", "monospace"]
    ax.text(-1, 1, "family", fontsize=18, horizontalalignment="center")
    for i, family in enumerate(families):
        ax.text(-1, pi[i], family, family=family, horizontalalignment="center")
    
    
    
    
        
    sizes=["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"]
    ax.text(-0.5, 1, "size", fontsize=18, horizontalalignment="center")
    for i, size in enumerate(sizes):
        ax.text(-0.5, pi[i], size, size=size, horizontalalignment="center")
    
    
      
    
    
    
    styles=["normal", "italic", "oblique"]
    ax.text(0, 1, "style", fontsize=18, horizontalalignment="center")
    for i, style in enumerate(styles):
        ax.text(0, pi[i], style, family="sans-serif", style=style, horizontalalignment="center")
    
    
    
    
    
    variants=["normal", "small-caps"]
    ax.text(0.5, 1, "variant", fontsize=18, horizontalalignment="center")
    for i, variant in enumerate(variants):
        ax.text(0.5, pi[i], variant, family="serif", variant=variant, horizontalalignment="center")
    
    
    
    
    
    
    weights=["light", "normal", "semibold", "bold", "black"]
    ax.text(1, 1, "weight", fontsize=18, horizontalalignment="center")
    for i, weight in enumerate(weights):
        ax.text(1, pi[i], weight, weight=weight, horizontalalignment="center")
    
    
    
    
    
    ax.axis([-1.5, 1.5, 0.1, 1.1])
    ax.set_xticks([])
    ax.set_yticks([])
    
    plt.show()
    View Code

    ==================================

    本博客是博主个人学习时的一些记录,不保证是为原创,个别文章加入了转载的源地址还有个别文章是汇总网上多份资料所成,在这之中也必有疏漏未加标注者,如有侵权请与博主联系。
  • 相关阅读:
    SOA设计模式
    MVC架构设计模式
    12周总结
    11周总结
    window环境pycharm中使用cityscapes数据集训练deeplabv3+经验总结
    分析六大质量属性战术
    《一线架构师实践指南》第三章阅读笔记
    pip install 无法安装cv2
    PHP disable_functions Bypass
    MallBuilder逻辑后门(复现)
  • 原文地址:https://www.cnblogs.com/devilmaycry812839668/p/13258734.html
Copyright © 2020-2023  润新知