python圖例位置_Python | 圖例位置

python圖例位置

Legends are one of the key components of data visualization and plotting. Matplotlib can automatically define a position for a legend in addition to this, it allows us to locate it in our required positions. Following is the list of locations on which we can locate our plot legend.

圖例是數據可視化和繪圖的關鍵組成部分之一。 Matplotlib可以為此自動定義圖例的位置,它使我們能夠將其定位在所需的位置。 以下是我們可以在其中找到圖例的位置的列表。

Python | Legend Locations (1)
Python | Legend Locations (2)
Python | Legend Locations (3)
Python | Legend Locations (4)

圖例位置的Python代碼 (Python code for legend locations)

# Data Visualization using Python
# Adding a Legend Location
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2, 100)
# Example 1
plt.figure()
plt.plot(x, x+2, label='linear')  
plt.plot(x, x**2, label='quadratic')  
plt.plot(x, x**3, label='cubic')
plt.xlabel('x label')
plt.ylabel('y label')
plt.title("lower right")
plt.legend(loc='lower right')
# Example 2
plt.figure()
x = np.linspace(0.0, 5.0)
y = x*x
plt.subplot(2, 1, 2)
plt.plot(x, y, 'g.-',label='quadratic')
plt.plot(x,x, 'r.-', label='linear')
plt.title('uper left')
plt.xlabel('numbers')
plt.ylabel('Square')
plt.legend(loc='uper left')
plt.show()
# Example 3
# Random Bar Graph Example
plt.figure()
plt.bar(np.arange(26), np.random.randint(0,50,26), alpha = 0.5, color='g', label='Legend Bar Graph')
plt.title('center right')
plt.legend(loc='center right')

Output:

輸出:

Output is as figure

翻譯自: https://www.includehelp.com/python/legend-locations.aspx

python圖例位置

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377164.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377164.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377164.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Freemarker中遍歷List實例

Freemarker中如何遍歷List摘要:在Freemarker應用中經常會遍歷List獲取需要的數據,并對需要的數據進行排序加工后呈現給用戶。那么在Freemarker中如何遍歷List,并對List中數據進行適當的排序呢?通過下文的介紹,相信您一…

工作總結:文件對話框的分類(C++)

原文地址:http://www.jizhuomi.com/software/173.html 文件對話框分為打開文件對話框和保存文件對話框,相信大家在Windows系統中經常見到這兩種文件對話框。例如,很多編輯軟件像記事本等都有“打開”選項,選擇“打開”后會彈出一個…

《MySQL——Innodb改進LRU算法》

Innodb改進LRU.算法,實質上將內存鏈表分成兩段。 靠近頭部的young和靠近末尾的old,取5/12段為分界。 新數據在一定時間內只能在old段的頭部,當在old段保持了一定的時間后被再次訪問才能升級到young。 實質上是分了兩段lru,這樣做的…

nfc/nfc模式_NFC的完整形式是什么?

nfc/nfc模式NFC:沒有進一步評論 (NFC: No Further Comment) NFC is an abbreviation of "No Further Comment". NFC是“沒有進一步評論”的縮寫 。 It is an expression, which is commonly used in messaging or chatting on social media networking s…

dx小記(2)

1.構造一個平截臺體(Frustum) 最近距離-projMatirx.43/projMatrix.33 projMatrix。33 深度/(深度-最近距離) projMatrix。44-最近距離*(深度/(深度-最近距離)) FrustumMatrix proje…

jQuery: 整理4---創建元素和添加元素

1.創建元素&#xff1a;$("內容") const p "<p>這是一個p標簽</p>" console.log(p)console.log($(p)) 2. 添加元素 2.1 前追加子元素 1. 指定元素.prepend(內容) -> 在指定元素的內部的最前面追加內容&#xff0c;內容可以是字符串、…

Design a high performance cache for multi-threaded environment

如何設計一個支持高并發的高性能緩存庫 不 考慮并發情況下的緩存的設計大家應該都比較清楚&#xff0c;基本上就是用map/hashmap存儲鍵值&#xff0c;然后用雙向鏈表記錄一個LRU來用于緩存的清理。這篇文章 應該是講得很清楚http://timday.bitbucket.org/lru.html。但是考慮到高…

《MySQL——join語句優化tips》

目錄要不要用joinJoin驅動表選擇Multi-Range Read優化Batched Key Access &#xff08;BKA&#xff09;對NLJ進行優化BNL算法性能問題BNL轉BKA要不要用join 1、如果使用的是Index Nested-Loop Join算法&#xff0c;即可以用上被驅動表的索引&#xff0c;可以用 2、如果使用的…

scala中抽象類_Scala中的抽象類

scala中抽象類抽象類 (Abstract Class) In the Scala programming language, abstraction is achieved using abstract class. 在Scala編程語言&#xff0c; 抽象是使用抽象類來實現的。 Abstraction is the process of showing only functionality and hiding the details fr…

不能catch Fatal的exception

Clemens Vasters - Are you catching falling knives?里給了一個判斷C#的exception是不是fatal的代碼&#xff0c;可以參考參考。 public static bool IsFatal(this Exception exception) {while (exception ! null){if (exception as OutOfMemoryException ! null &&…

HDU 2824 The Euler function

篩法計算歐拉函數 #include <iostream> #include <cstdio> using namespace std; const int maxn3000005; long long phi[maxn]; int main(){int i,j,a,b;for(i1;i<maxn;i) phi[i]i;for(i2;i<maxn;i2) phi[i]/2;for(i3;i<maxn;i2)if(phi[i]i){for(ji;j<…

LinkChecker 8.1 發布,網頁鏈接檢查

LinkChecker 8.1 可對檢查時間和最大的 URL 數量進行配置&#xff1b;當使用 HTTP 請求時發送 do-not-track 頭&#xff1b;生成 XML 的 sitemap 用于搜索引擎優化&#xff1b;檢測 URL 長度和重復的頁面內容&#xff1b;修復了很多檢查的 bug。 LinkChecker 是一個網頁鏈接檢查…

c語言語言教程0基礎_C語言基礎

c語言語言教程0基礎Hey, Folks here I am back with my second article on C language. Hope you are through with my previous article C language - History, Popularity reasons, Characteristics, Basic structure etc. In this one, I will cover some fundamental conce…

《MySQL——臨時表》

內存表與臨時表區別 臨時表&#xff0c;一般是人手動創建。 內存表&#xff0c;是mysql自動創建和銷毀的。 內存表&#xff0c;指的是使用Memory引擎的表&#xff0c;建表語法&#xff1a;create table ... engine memeory 表的數據存在內存里&#xff0c;系統重啟后會被清…

android中ActionBar的幾個屬性

actionBar.setHomeButtonEnabled //小于4.0版本的默認值為true的。但是在4.0及其以上是false&#xff0c;該方法的作用&#xff1a;決定左上角的圖標是否可以點擊。沒有向左的小圖標。 true 圖標可以點擊 false 不可以點擊。 actionBar.setDisplayHomeAsUpEnabled(true) //…

drei

模擬9 T3 &#xff08;COGS上也有&#xff0c;鏈接http://218.28.19.228/cogs/problem/problem.php?pid1428&#xff09; 題目描述 輸入a&#xff0c;p&#xff0c;求最小正整數x&#xff0c;使得a^x mod p 1。 分析 神奇的歐拉定理&#xff08;對于gcd&#xff08;a&#xf…

《MySQL——group by使用tips》

1、如果對group by語句結果沒有排序要求&#xff0c;在語句后面加order by null 2、盡量讓group by 過程用上索引&#xff0c;確認方法是explain結果里沒有Using temporary 和Using filesort 3、如果group by 需要統計的數據量不大&#xff0c;盡量只使用內存臨時表&#xff…

css中變量_CSS中的變量

css中變量CSS | 變數 (CSS | Variables) CSS variables allow you to create reusable values that can be used throughout a CSS document. CSS變量允許您創建可在CSS文檔中使用的可重用值。 In CSS variable, function var() allows CSS variables to be accessed. 在CSS變…

位圖像素的顏色 攜程編程大賽hdu

位圖像素的顏色 Time Limit: 2000/1000 MS (Java/Others) MemoryLimit: 32768/32768 K (Java/Others) Total Submission(s): 0 Accepted Submission(s): 0 Problem Description 有一個在位圖上畫出矩形程序&#xff0c;一開始位圖都被初始化為白色&#xff08;RGB顏色表示…

《MySQL——InnoDB與Memory以及臨時表》

InooDB與Memory 數據組織方式不同&#xff1a; InnoDB引擎把數據放在主鍵索引上&#xff0c;其他索引上保存的是主鍵id。為索引組織表Memory引擎把數據單獨存放&#xff0c;索引上保存數據位置。為堆組織表 典型不同處&#xff1a; 1、InnoDB表的數據總是有序存放的&#x…