2000年国赛B题“钢管订购和运输”---python

一、有关Python的细节操作

1.将plt横坐标变成百分号形式

import matplotlib.pyplot as plt 
from matplotlib.ticker import FuncFormatter
plt.rcParams['font.family'] = ['Times New Roman']
plt.rcParams.update({'font.size': 8}) 
x = range(11)
y = range(11)
plt.plot(x, y)
 
def to_percent(temp, position):
    return '%1.0f'%(10*temp) + '%'
plt.gca().yaxis.set_major_formatter(FuncFormatter(to_percent))
plt.gca().xaxis.set_major_formatter(FuncFormatter(to_percent))
 
plt.show()

(关键代码在plot后面)

2.小数range的写法(借助np.arange())

labels=["{}%".format(i) for i in np.arange(-10.0,10.0,5)]

 3.深拷贝

import copy
a_copy=copy.deepcopy(a)

你可能感兴趣的:(用Python进行数学建模,算法,python)