上QQ阅读APP看书,第一时间看更新
How to do it...
The following block of code along with comments helps you to understand the process of changing and resetting default environment variables:
- Import the matplotlib.pyplot package with the plt synonym:
import matplotlib.pyplot as plt
- Load x and y variables from same test.csv file that we used in the preceding recipe:
x, y = np.loadtxt ('test.csv', unpack = True, usecols = (0,1),
delimiter = ',')
- Change the default values for multiple parameters within the group 'lines':
matplotlib.rc('lines', linewidth=4, linestyle='-', marker='*')
- Change the default values for parameters individually:
matplotlib.rcParams['lines.markersize'] = 20
matplotlib.rcParams['font.size'] = '15.0'
- Plot the graph:
plt.plot(x,y)
- Display the graph:
plt.show()
The following is the output that will be obtained: