from matplotlib.patches import Rectangle
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10, 5))
# matplotlib.rcParams['font.family'] = 'SimHei' # 设置字体为中文宋体
ax.set_ylim(0, 5)
ax.set_xlim(0, 10)
ax.grid()
ax.scatter(6, 3, color='red', marker="*")
ax.tick_params(size=12)
patch = mpatches.Patch(color='blue', label='legend')
ax.legend(handles=[patch], loc='upper left',
bbox_to_anchor=(6/10, 3/5),
borderaxespad=0,
fontsize=18, edgecolor='yellow')
# ax.annotate('(14, 6)', xy=(14, 6), xytext=(15, 6.5),arrowprops={'arrowstyle':'->'}, fontsize=18)
ax.text(5.5, 3.3,
'The point at upper left of legend matches (x, y)',
fontsize=18)
![Python: matplotlib如何控制legend的位置? ax.legend(handles=[patch], loc='upper left', bbox_to_anchor=(6/10, 3/5) - 儲蓄保險王](https://savingking.com.tw/wp-content/uploads/2023/05/20230502163945_79.png)
推薦hahow線上學習python: https://igrape.net/30afN
![Python: pandas.DataFrame如何移除所有空白列?if df_raw.iloc[r,0] is np.nan: nanLst.append(r) ; df_drop0 = df_raw.drop(nanLst,axis=0) ; pandas.isna() ;df_drop0 = df_raw.drop(nanLst,axis=0).reset_index(drop=True) Python: pandas.DataFrame如何移除所有空白列?if df_raw.iloc[r,0] is np.nan: nanLst.append(r) ; df_drop0 = df_raw.drop(nanLst,axis=0) ; pandas.isna() ;df_drop0 = df_raw.drop(nanLst,axis=0).reset_index(drop=True)](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2022/12/20221206144233_67.png?quality=90&zoom=2&ssl=1&resize=350%2C233)






![Python: pandas.DataFrame 如何找出重複值並計算重複次數? counts = df[duplicates] .groupby([‘name’]) .size() .reset_index(name=’count’) Python: pandas.DataFrame 如何找出重複值並計算重複次數? counts = df[duplicates] .groupby([‘name’]) .size() .reset_index(name=’count’)](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2023/03/20230316131103_65.png?quality=90&zoom=2&ssl=1&resize=350%2C233)


近期留言