日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術文章
文章詳情頁

Python 作圖實現坐標軸截斷(打斷)的效果

瀏覽:30日期:2022-06-22 10:54:25

主題:利用python畫圖實現坐標軸截斷或打斷

關鍵詞:python, plot, matplotlib, break axes

方法一:

首先介紹一種簡單快速的方法——調用包 brokenaxes。

詳細請點擊參考

import matplotlib.pyplot as pltfrom brokenaxes import brokenaxesimport numpy as npfig = plt.figure(figsize=(5,2))bax = brokenaxes(xlims=((0, .1), (.4, .7)), ylims=((-1, .7), (.79, 1)), hspace=.05, despine=False)x = np.linspace(0, 1, 100)bax.plot(x, np.sin(10 * x), label=’sin’)bax.plot(x, np.cos(10 * x), label=’cos’)bax.legend(loc=3)bax.set_xlabel(’time’)bax.set_ylabel(’value’)

效果如下:

Python 作圖實現坐標軸截斷(打斷)的效果

方法二:

拼接法,該種方法代碼更繁瑣,但更有可能滿足個性化的需求。

請點擊參考鏈接

'''Broken axis example, where the y-axis will have a portion cut out.'''import matplotlib.pyplot as pltimport numpy as np# 30 points between [0, 0.2) originally made using np.random.rand(30)*.2pts = np.array([ 0.015, 0.166, 0.133, 0.159, 0.041, 0.024, 0.195, 0.039, 0.161, 0.018, 0.143, 0.056, 0.125, 0.096, 0.094, 0.051, 0.043, 0.021, 0.138, 0.075, 0.109, 0.195, 0.050, 0.074, 0.079, 0.155, 0.020, 0.010, 0.061, 0.008])# Now let’s make two outlier points which are far away from everything.pts[[3, 14]] += .8# If we were to simply plot pts, we’d lose most of the interesting# details due to the outliers. So let’s ’break’ or ’cut-out’ the y-axis# into two portions - use the top (ax) for the outliers, and the bottom# (ax2) for the details of the majority of our dataf, (ax, ax2) = plt.subplots(2, 1, sharex=True)# plot the same data on both axesax.plot(pts)ax2.plot(pts)# zoom-in / limit the view to different portions of the dataax.set_ylim(.78, 1.) # outliers onlyax2.set_ylim(0, .22) # most of the data# hide the spines between ax and ax2ax.spines[’bottom’].set_visible(False)ax2.spines[’top’].set_visible(False)ax.xaxis.tick_top()ax.tick_params(labeltop=’off’) # don’t put tick labels at the topax2.xaxis.tick_bottom()# This looks pretty good, and was fairly painless, but you can get that# cut-out diagonal lines look with just a bit more work. The important# thing to know here is that in axes coordinates, which are always# between 0-1, spine endpoints are at these locations (0,0), (0,1),# (1,0), and (1,1). Thus, we just need to put the diagonals in the# appropriate corners of each of our axes, and so long as we use the# right transform and disable clipping.d = .015 # how big to make the diagonal lines in axes coordinates# arguments to pass to plot, just so we don’t keep repeating themkwargs = dict(transform=ax.transAxes, color=’k’, clip_on=False)ax.plot((-d, +d), (-d, +d), **kwargs)# top-left diagonalax.plot((1 - d, 1 + d), (-d, +d), **kwargs) # top-right diagonalkwargs.update(transform=ax2.transAxes) # switch to the bottom axesax2.plot((-d, +d), (1 - d, 1 + d), **kwargs) # bottom-left diagonalax2.plot((1 - d, 1 + d), (1 - d, 1 + d), **kwargs) # bottom-right diagonal# What’s cool about this is that now if we vary the distance between# ax and ax2 via f.subplots_adjust(hspace=...) or plt.subplot_tool(),# the diagonal lines will move accordingly, and stay right at the tips# of the spines they are ’breaking’plt.show()

效果如下:

Python 作圖實現坐標軸截斷(打斷)的效果

補充:python繪制折線圖--縱坐標y軸截斷

看代碼吧~

# -*- coding: utf-8 -*-'''Created on Wed Dec 4 21:50:38 2019@author: muli'''import matplotlib.pyplot as pltfrom pylab import * mpl.rcParams[’font.sans-serif’] = [’SimHei’] #支持中文 names = ['1','2','3','4','5'] # 刻度值命名x = [1,2,3,4,5] # 橫坐標y3= [2,3,1,4,5] # 縱坐標y4= [4,6,8,5,9] # 縱坐標y5=[24,27,22,26,28] # 縱坐標f, (ax3, ax) = plt.subplots(2, 1, sharex=False) # 繪制兩個子圖plt.subplots_adjust(wspace=0,hspace=0.08) # 設置 子圖間距ax.plot(x, y3, color=’red’, marker=’o’, linestyle=’solid’,label=u’1’) # 繪制折線ax.plot(x, y4, color=’g’, marker=’o’, linestyle=’solid’,label=u’2’) # 繪制折線plt.xticks(x, names, rotation=45) # 刻度值ax3.xaxis.set_major_locator(plt.NullLocator()) # 刪除坐標軸的刻度顯示ax3.plot(x, y5, color=’blue’, marker=’o’, linestyle=’solid’,label=u’3’) # 繪制折線ax3.plot(x, y3, color=’red’, marker=’o’, linestyle=’solid’,label=u’1’) # 起圖例作用ax3.plot(x, y4, color=’g’, marker=’o’, linestyle=’solid’,label=u’2’) # 起圖例作用ax3.set_ylim(21, 30) # 設置縱坐標范圍ax.set_ylim(0, 10) # 設置縱坐標范圍ax3.grid(axis=’both’,linestyle=’-.’) # 打開網格線ax.grid(axis=’y’,linestyle=’-.’) # 打開網格線ax3.legend() # 讓圖例生效plt.xlabel(u'λ') #X軸標簽plt.ylabel('mAP') #Y軸標簽ax.spines[’top’].set_visible(False) # 邊框控制ax.spines[’bottom’].set_visible(True) # 邊框控制ax.spines[’right’].set_visible(False) # 邊框控制ax3.spines[’top’].set_visible(False) # 邊框控制ax3.spines[’bottom’].set_visible(False) # 邊框控制ax3.spines[’right’].set_visible(False) # 邊框控制ax.tick_params(labeltop=’off’) # 繪制斷層線d = 0.01 # 斷層線的大小kwargs = dict(transform=ax3.transAxes, color=’k’, clip_on=False)ax3.plot((-d, +d), (-d, +d), **kwargs)# top-left diagonalkwargs.update(transform=ax.transAxes, color=’k’) # switch to the bottom axesax.plot((-d, +d), (1 - d, 1 + d), **kwargs) # bottom-left diagonalplt.show()

結果如圖所示:

Python 作圖實現坐標軸截斷(打斷)的效果

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。如有錯誤或未考慮完全的地方,望不吝賜教。

標簽: Python 編程
相關文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
激情中国色综合| 久久uomeier| 精品国产免费人成网站| 欧美亚洲一级| 午夜精品婷婷| 亚洲午夜黄色| 国产精品蜜芽在线观看| 欧美国产专区| 国产日产高清欧美一区二区三区| 蜜臀av性久久久久蜜臀aⅴ四虎| 国产综合婷婷| 自由日本语亚洲人高潮| 久久精品国产亚洲夜色av网站| 亚洲免费福利| 久久一级电影| 激情综合自拍| 亚洲深深色噜噜狠狠爱网站 | 91看片一区| 色爱av综合网| 日韩一区二区三区免费播放| 欧美va亚洲va日韩∨a综合色| 欧美黄色网页| 日韩精品影视| 久久精品国语| 精品一区毛片| 一区二区国产精品| 日韩在线观看中文字幕| 亚洲3区在线| 亚洲毛片一区| 91大神在线观看线路一区| 一区二区精彩视频| 亚洲一区二区小说| 国产精品免费不| 精品视频自拍| 亚洲手机在线| 欧美特黄a级高清免费大片a级| 久久久久免费av| 欧美aa在线观看| 黄色aa久久| 国产亚洲精品久久久久婷婷瑜伽| 99国产精品自拍| 视频一区二区中文字幕| 日韩在线黄色| 久久不卡国产精品一区二区| 日韩国产一区| 精品日韩毛片| 国产福利亚洲| 久久天堂av| 999精品在线| 色综合视频一区二区三区日韩 | 五月婷婷亚洲| 丝袜亚洲另类欧美| 色综合视频一区二区三区日韩| 国产精品大片| 日韩精品中文字幕第1页| 麻豆久久精品| 噜噜噜躁狠狠躁狠狠精品视频 | 亚洲欧美日韩国产一区二区| 国产亚洲久久| 国产白浆在线免费观看| 久久精品国产大片免费观看| 蜜桃一区二区三区在线| 精品一区二区三区中文字幕在线| 在线一区视频观看| 免费一级片91| 综合日韩av| 在线视频免费在线观看一区二区| 国产欧美日韩精品高清二区综合区| 国产一区二区三区网| 亚洲精品午夜av福利久久蜜桃| 国产免费久久| 婷婷丁香综合| 日韩成人一级| 久草免费在线视频| 伊人久久成人| 欧美韩一区二区| 亚洲精品一区二区妖精| 国产精品chinese| 亚洲黄色在线| 亲子伦视频一区二区三区| 综合欧美亚洲| 在线人成日本视频| 久久国产精品亚洲77777| 国产精品超碰| 1024精品久久久久久久久| 在线日韩中文| 91精品福利观看| 99热精品久久| 日本不卡在线视频| 久久精品国产www456c0m| 久久国产三级精品| 国产不卡一区| 久久激情五月婷婷| 免费毛片在线不卡| 欧美激情福利| 亚洲综合日本| 激情久久五月| 国产精品成人国产| 日精品一区二区三区| 136国产福利精品导航网址| 精品免费av一区二区三区| 亚洲精品护士| 香蕉久久精品| 国产精品宾馆| 亚洲制服欧美另类| 婷婷综合六月| 国产精品欧美大片| 美国欧美日韩国产在线播放| 蜜桃国内精品久久久久软件9| 精品国产不卡| 日韩中文字幕麻豆| 在线一区免费观看| 成人va天堂| 日本久久综合| 欧美日韩午夜| 日韩高清二区| 日韩精品一级二级 | 成人福利视频| 国产精品高潮呻吟久久久久| 欧美日韩亚洲三区| 丝袜亚洲另类欧美| 激情欧美亚洲| 日本激情一区| 久久99久久人婷婷精品综合| 国产欧美日韩| 欧美在线观看天堂一区二区三区| 日韩欧美美女在线观看| 欧美日韩第一| 国产欧美三级| 一区二区三区四区日韩| 最新日韩欧美| 亚洲在线观看| 亚洲少妇诱惑| 久久九九精品| 亚洲1234区| 日韩一区二区三区免费播放| 国内在线观看一区二区三区| 免费在线成人| 精品99在线| 国内精品伊人| 国精品产品一区| 精品国产三区在线| 日韩欧美精品综合| 成人一区而且| 国产日韩免费| 久久精品一区二区国产| 国产精品观看| 国产传媒在线观看| 国产一区二区视频在线看| 欧美亚洲日本精品| 免费高潮视频95在线观看网站| 亚洲高清毛片| 99国内精品| 免费一区二区视频| 日本va欧美va精品发布| 日韩欧美2区| 国产亚洲精品美女久久| 国产精品亚洲欧美一级在线| 国产精品流白浆在线观看| 国产精品对白| 日韩在线高清| 欧美/亚洲一区| 99久久激情| 丝袜诱惑制服诱惑色一区在线观看 | 日本亚洲最大的色成网站www| 久久精品99久久久| 久久99久久久精品欧美| 福利一区二区免费视频| 国产欧洲在线| 亚洲精品成人图区| 欧美中文字幕一区二区| 99国产成+人+综合+亚洲欧美| 亚洲精品免费观看| 久久国产欧美日韩精品| 国产suv精品一区| 久久精品电影| 日韩激情av在线| 国产精品tv| 国产麻豆一区二区三区精品视频| 你懂的国产精品永久在线| 91欧美极品| 中文字幕在线高清| 99久久激情| 日本a级不卡| 国语对白精品一区二区| 视频在线在亚洲| 国产亚洲精品美女久久 | 99热精品在线观看| 日本中文字幕视频一区| 欧美激情另类| 狠狠久久婷婷| 国产精品白丝av嫩草影院| 亚洲va中文在线播放免费| 亚洲精品麻豆| 久久精品xxxxx| 日韩精品网站| 日本一区免费网站| 久久国产免费看| 亚洲免费福利| 亚洲一区二区三区四区电影 |