程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[Python] use Matplotlib to draw the scale line inward

編輯:Python

I don't say much nonsense , Look at the renderings first :


The following only discusses how to realize matplotlib The scale in the drawing faces inward , Other settings such as fonts 、 The coordinate axis is not considered .

The following code is based on :
python edition 3.6.10
numpy edition 1.19.3
matplotlib edition 3.2.1

1. Initial drawing
import numpy as np
import matplotlib.pyplot as plt
nums = np.arange(10).reshape(2,5)
x = nums[0]
y = nums[1]
plt.figure()
plt.plot(x,y)
plt.savefig("1.png",dpi=600)

2. Modify the scale direction drawing
import numpy as np
import matplotlib.pyplot as plt
nums = np.arange(10).reshape(2,5)
x = nums[0]
y = nums[1]
plt.figure()
plt.rcParams['xtick.direction']='in'
plt.rcParams['ytick.direction']='in'
plt.plot(x,y)
plt.savefig("1_post.png",dpi=600)


The main setting is plt.plot(x,y) Previously set the scale direction :

plt.rcParams['xtick.direction']='in'
plt.rcParams['ytick.direction']='in'

Reference resources :
https://zhuanlan.zhihu.com/p/448571003
https://wenku.baidu.com/view/d63d7f7cbd23482fb4daa58da0116c175e0e1e5a.html


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved