Ubuntu 管理心得

搜尋此網誌

顯示具有 Matplotlib 標籤的文章。 顯示所有文章
顯示具有 Matplotlib 標籤的文章。 顯示所有文章

2023年7月22日 星期六

The label function was deprecated in Matplotlib 3.1

Change
tick.label.set_fontsize(18)
to
tick.label1.set_fontsize(18)


2022年2月17日 星期四

Matplotlib 顯示中文

 cf: https://mathsyouth.github.io/2019/06/12/macos-matplotlib

  1. Run shell command:
    fc-list :lang=zh

    to find the fonts pathes, e.g. /usr/share/fonts/truetype/bkai00mp.ttf
  2. Follow the python codes below:
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rcParams
    from matplotlib.font_manager import FontProperties
    rcParams['axes.unicode_minus']=False
    myfont_kai=FontProperties(fname='/usr/share/fonts/truetype/bkai00mp.ttf', size=15)
    myfont_ming=FontProperties(fname='/usr/share/fonts/truetype/arphic-bsmi00lp/bsmi00lp.ttf',size=12)
    x=np.linspace(0,2*np.pi,100)
    plt.plot(x,x)
    plt.title("準則", fontproperties=myfont_kai)
    plt.ylabel("隸屬度", fontproperties=myfont_ming)

2020年7月11日 星期六

Repeat duplicate items in legend in Matplotlb jupyter

In unbuntu 18.04 this is not an error, however, it will produce duplicated legend in ubuntu 20.04. According to https://stackoverflow.com/questions/19385639/duplicate-items-in-legend-in-matplotlib, if plot the same line type twice, then it will produce the same lengend for the same line.
Therefore, I have to break the oringial one line into two lines:

    ax.plot(x, yU, Label=i,linewidth=2, dashes=dst,color='black')
    ax.plot(x, yL, linewidth=2, dashes=dst,color='black')
NB, the legend is removed from the second line.

2019年1月24日 星期四

dash style

cf: /home/chiao/Fuzzy/Papers/2019/0623FUZZ-IEEE/papers/example/Matplotlib/exm.ipynb

#[8, 4, 6, 2] means: 8pt. line + 4pt. break + 6pt. line + 2pt. break ]
dstary=[[1,0],[8, 2],[5, 2], [3,2], [1,2]]
ax.plot(x, yL,label=labl,linewidth=2, dashes=dstary[1], color='black')

網誌存檔