日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python legend位置_关于matplotlib-legend 位置属性 loc 使用说明

發布時間:2024/1/23 python 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python legend位置_关于matplotlib-legend 位置属性 loc 使用说明 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在使用matplotlib畫圖時,少不了對性能圖形做出一些說明和補充。一般情況下,loc屬性設置為'best'就足夠應付了

plt.legend(handles = [l1, l2,], labels = ['a', 'b'], loc = 'best')

或直接loc = 0

plt.legend(handles = [l1, l2,], labels = ['a', 'b'], loc = 0)

除'best',另外loc屬性有:

'upper right', 'upper left', 'lower left', 'lower right', 'right', 'center left', 'center right', 'lower center', 'upper center', 'center'

不說太多,上面是全部的快捷使用,滿足一般需求。

demo:

import matplotlib.pyplot as plt

import numpy as np

# 繪制普通圖像

x = np.linspace(-1, 1, 50)

y1 = 2 * x + 1

y2 = x**2

plt.figure()

# 在繪制時設置lable, 逗號是必須的

l1, = plt.plot(x, y1, label = 'line')

l2, = plt.plot(x, y2, label = 'parabola', color = 'red', linewidth = 1.0, linestyle = '--')

# 設置坐標軸的取值范圍

plt.xlim((-1, 1))

plt.ylim((0, 2))

# 設置坐標軸的lable

plt.xlabel('X axis')

plt.ylabel('Y axis')

# 設置x坐標軸刻度, 原來為0.25, 修改后為0.5

plt.xticks(np.linspace(-1, 1, 5))

# 設置y坐標軸刻度及標簽, $$是設置字體

plt.yticks([0, 0.5], ['$minimum$', 'normal'])

# 設置legend

plt.legend(handles = [l1, l2,], labels = ['a', 'b'], loc = 'best')

plt.show()

運行結果:

補充知識:設置圖列(key/legend)的位置和大小 --gnuplot

先看幾個例子:

//不顯示圖例。

unset key

//設置圖例 顯示在圖形(內)的頂部居中,并且多個圖例水平顯示。

set key top horizontal center

//設置圖例 顯示在圖形(外)的頂部居中,并且多個圖例水平顯示。

set key top outside horizontal center

//設置圖例 顯示的字體并加粗。

set key font "Times,18,Bold"

//調整圖例行間隔

set key spacing 3

//調整圖例中線段示例長度

set key samplen 2

set key 的語法規則

Syntax:

set key {on|off} {default}

{{inside | outside} | {lmargin | rmargin | tmargin | bmargin}

| {at }}

{left | right | center} {top | bottom | center}

{vertical | horizontal} {Left | Right}

{{no}reverse} {{no}invert}

{samplen } {spacing }

{width }

{height }

{{no}autotitle {columnheader}}

{title ""} {{no}enhanced}

{{no}box { {linestyle | ls }

| {linetype | lt }

{linewidth | lw }}}

unset key

show key

Elements within the key are stacked according to vertical or horizontal. In the case of vertical, the key occupies as few columns as possible. That is, elements are aligned in a column until running out of vertical space at which point a new column is started. In the case of horizontal, the key occupies as few rows as possible.

圖例是依據我們設置的水平顯示或垂直顯示進行堆疊式地顯示。

對于垂直顯示,pnuplot會占用盡可能少的行來放置我們的圖例,當圖例在一行顯示不下時,它會另啟一行來顯示。

對于水平顯示方式,pnuplot會占用盡可能少的列來放置我們的圖例,當圖例在一列顯示不下時,它會另啟一列來放置。

The vertical spacing between lines is controlled by spacing. The spacing is set equal to the product of the pointsize, the vertical tic size, and vertical_spacing. The program will guarantee that the vertical spacing is no smaller than the character height.

The defaults for set key are on, right, top, vertical, Right, noreverse, noinvert, samplen 4, spacing 1.25, title “”, and nobox.

以上這篇關于matplotlib-legend 位置屬性 loc 使用說明就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

總結

以上是生活随笔為你收集整理的python legend位置_关于matplotlib-legend 位置属性 loc 使用说明的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲午夜电影网 | 天天看天天操 | 天堂在线一区 | 天堂综合网 | 亚洲综合av一区二区三区 | 狠狠伊人| 91精品国产色综合久久不卡蜜臀 | 国语对白永久免费 | 日韩色综合网 | 日本黄色xxxx | 中国老太婆性视频 | 在线观看欧美一区二区 | 一本色道久久88 | 91中文字日产乱幕4区 | 麻豆视频在线 | 欧美在线一二三 | www.啪啪 | 视频一区 国产 | 在线视频自拍 | 日韩人妻无码精品综合区 | 欧美精品黄 | a天堂在线 | 成人黄色免费在线观看 | 另类视频在线观看+1080p | 日韩精品一区二区免费视频 | 亚洲精品国产精品国自 | 久久人人爽人人爽人人av | 97超碰国产精品无码蜜芽 | 欧美黑粗大 | 精品国产三级片在线观看 | 蜜桃91精品入口 | 极品在线播放 | 一本大道久久精品 | 国产成人久久精品麻豆二区 | 殴美一区二区 | 欧美日韩亚洲免费 | 91嫩草精品 | 色就色综合 | 中国人妖和人妖做爰 | 精品国自产拍在线观看 | 日韩成人黄色片 | 久久久夜| 中文字幕久热 | 成人3d动漫在线观看 | 亚洲久久视频 | 欧美在线一级片 | 一二三av | 日韩簧片在线观看 | 免费观看黄色网页 | 免费人成视频在线播放 | 91黄色国产 | 国产精品成人一区 | 亚洲精品xxxxx | 亚洲一区二区电影网 | 日韩色黄大片 | 日韩精品一区二区三区在线视频 | 久久国内免费视频 | a极黄色片 | 一级做a爰片 | a亚洲天堂 | 男人的网站在线观看 | 久久久精品日韩 | 在线一区| 青青国产在线视频 | 国产精品91一区二区 | 操碰97| 操极品美女 | 男人的天堂97 | 久久综合婷婷 | 小泽玛利亚一区二区三区视频 | 先锋资源国产 | 探花国产精品一区二区 | 九一福利视频 | 亚洲精品一区二区三区不卡 | 波多野结衣中文在线 | 日韩中文字幕影院 | 精品国产三级a∨在线 | 中文字幕日韩欧美一区二区 | 亚洲一区二区自偷自拍 | 国产69精品一区二区 | 黄色网占 | 四虎成人精品永久免费av九九 | 日韩久久免费 | 网站免费视频www | 亚洲一区二区美女 | 色综合久久五月 | 91涩漫成人官网入口 | 人人妻人人澡人人爽 | 免费看的一级片 | 美女人人操 | 国内精品视频在线观看 | 美女黄污网站 | 91视频麻豆 | 天天摸天天操天天爽 | 老司机激情影院 | 在办公室被c到呻吟的动态图 | 精品成人av一区二区三区 | 午夜av剧场| 沟厕沟厕近拍高清视频 |