Matplotlib 3.0 Cookbook
上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: 

  1. Import the matplotlib.pyplot package with the plt synonym:
import matplotlib.pyplot as plt
  1. 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 = ',')
  1. Change the default values for multiple parameters within the group 'lines':
matplotlib.rc('lines', linewidth=4, linestyle='-', marker='*')
  1. Change the default values for parameters individually:
matplotlib.rcParams['lines.markersize'] = 20
matplotlib.rcParams['font.size'] = '15.0'
  1. Plot the graph:
plt.plot(x,y)
  1. Display the graph:
plt.show()

The following is the output that will be obtained: