有时默认的图例位置不符合我们的需要,那么我们可以使用下面的代码对legend位置进行调整. plt.legend(loc='String or Number', bbox_to_anchor=(num1, num2)) 其中,第一个参数loc,设置它可以遵循以下的表格 String Number upper right 1 upper left 2 lower left 3 lower right 4 right 5 center left 6 center right 7 lower cent
#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 def describe_pet(type,name): print(f"i have a {type}:") print(f"my {type}'s name is {name}!") describe_pet("dog","peter")
# -*- coding: utf-8 -*- """ Created on Mon Nov 30 13:24:00 2015 @author: jx_luo """ from pandas import DataFrame, Series import pandas as pd import numpy as np import matplotlib.pyplot as plt import matplotlib.font_manager as
1.二维绘图 a. 一维数据集 用 Numpy ndarray 作为数据传入 ply 1. import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt np.random.seed(1000) y = np.random.standard_normal(10) print "y = %s"% y x = range(len(y)) print "x=%s"% x plt.pl