当前位置:网站首页>Matplotlib common operations

Matplotlib common operations

2022-06-26 14:22:00 Chaoying.

  • Chinese and negative numbers are garbled
plt.rcParams['axes.unicode_minus'] = False  # Solve the problem that the negative sign cannot be displayed normally 
plt.rcParams['font.sans-serif'] = ['SimHei']
  • Coordinate axis setting
    • Set the axis range
    plt.xlim([x_min,x_max])
    plt.ylim([y_min,y_max])
    
    • Set the axis scale interval
    ax=plt.gca()# Get the current canvas 
    ax.xaxis.set_major_locator(plt.MultipleLocator(2))
    ax.yaxis.set_major_locator(plt.MultipleLocator(100))
    
  • Two sets of data of different types are in the same coordinate system ( The same X Axis , Different y Axis )
plt.twinx()
  • Column related settings
plt.legend(frameon=False,loc=`upper left`,bbox_to_anchor=(0.2,0.4))// Percentage shift right and percentage shift up , Take the bottom left corner as the origin 

loc Possible values
 Insert picture description here

原网站

版权声明
本文为[Chaoying.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170508311322.html