matplotlib字体大小相关设置
2017-06-05 21:58
483 查看
ax = plt.subplot(111) # 设置刻度字体大小 plt.xticks(fontsize=20) plt.yticks(fontsize=20) # 设置坐标标签字体大小 ax.set_xlabel(..., fontsize=20) ax.set_ylabel(..., fontsize=20) # 设置图例字体大小 ax.legend(..., fontsize=20) 选择如何显示刻度 ax.xaxis.set_ticks_position(‘none’) ax.yaxis.set_ticks_position(‘right’) import matplotlib.pyplot as plt import numpy as np x = np.arange(1, 11) fig = plt.figure(1) ax1 = plt.subplot(2, 1, 1) ax2 = plt.subplot(2, 1, 2) l1, = ax1.plot(x, x*x, 'r') #这里关键哦 l2, = ax2.plot(x, x*x, 'b') # 注意 plt.legend([l1, l2], ['first', 'second'], loc = 'upper right') #其中,loc表示位置的; plt.show() 'best' : 0, (only implemented for axes legends)(自适应方式) 'upper right' : 1, 'upper left' : 2, 'lower left' : 3, 'lower right' : 4, 'right' : 5, 'center left' : 6, 'center right' : 7, 'lower center' : 8, 'upper center' : 9, 'center' : 10, Keyword Description loc a location code prop the font property (matplotlib.font_manager.FontProperties 对象) eg song_font = matplotlib.font_manager.FontProperties(fname='simsun.ttc', size=8) fontsize the font size (和prop互斥,不可同时使用) markerscale the relative size of legend markers vs. original numpoints the number of points in the legend for line scatterpoints the number of points in the legend for scatter plot scatteryoffsets a list of yoffsets for scatter symbols in legend frameon if True, draw a frame around the legend. If None, use rc fancybox if True, draw a frame with a round fancybox. If None, use rc shadow if True, draw a shadow behind legend ncol number of columns borderpad the fractional whitespace inside the legend border labelspacing the vertical space between the legend entries handlelength the length of the legend handles handleheight the length of the legend handles handletextpad the pad between the legend handle and text borderaxespad the pad between the axes and legend border columnspacing the spacing between columns title the legend title bbox_to_anchor the bbox that the legend will be anchored. bbox_transform the transform for the bbox. transAxes if None.
相关文章推荐
- python matplotlib 画图刻度、图例等字体、字体大小设置
- python matplotlib 画图刻度、图例等字体、字体大小设置
- 使用matplotlib的示例:调整字体-设置刻度、坐标、colormap和colorbar等
- python中matplotlib的颜色及线条控制【以及改变legend字体大小】
- python matplotlib 中文字体设置
- 使用matplotlib的示例:调整字体-设置colormap和colorbar
- 用matplotlib绘制带误差的条形图及中英文字体设置
- 使用matplotlib的示例:调整字体-设置刻度、坐标、colormap和colorbar等
- Matplotlib 中文字体设置
- python Matplotlib画图之调整字体大小的示例
- ubuntu下matplotlib中文字体的设置
- matplotlib中字体设置问题
- matplotlib(刻度,刻度线长短位置相关设置)
- 使用matplotlib的示例:调整字体-设置colormap和colorbar
- python—matplotlib数据可视化实例注解系列-----设置标注字体样式(matplotlib颜色库)
- Matplotlib画图之调整字体大小
- 如何设定数字标题和坐标轴标签字体大小matplotlib
- python安装,以及matplotlib及相关组件安装。
- 【Matplotlib】设置刻度(1)
- Matplotlib 图例中文显示(大小修改)