Matplotlib 繪圖與可視化 一些控件的介紹和屬性,反正就是亂七八糟的

這個連接裏有下面這個圖(圖裏還有超連接):https://matplotlib.org/3.1.1/api/artist_api.html#matplotlib.artist.Artisthtml

各類圖例:(能夠在不知道想要功能的基類時在這裏面找):https://matplotlib.org/gallery/index.htmlpython

 

未分類:

get_xticklabels()返回一個text object的list,能夠參考text object的屬性來設置想要的功能express

  text:https://matplotlib.org/3.1.1/api/text_api.html#matplotlib.text.Textcanvas

 

設置label的offset的:class matplotlib.text.Text   的 horizontalalignment 屬性:api

  參考連接:https://matplotlib.org/3.1.1/api/text_api.html#matplotlib.text.Text數組

legend:圖例

  參考連接:https://matplotlib.org/users/legend_guide.html(未看完)
ide

  基礎連接:https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.figlegend(未看完)函數

  裏面有怎麼爲plot添加圖例的,包括位置、顏色、形狀和label說明佈局

 

知道base class的

figure:

  能夠理解爲畫板(還有一個大寫的Figure)ui

  參考連接:https://matplotlib.org/3.1.1/api/figure_api.html?highlight=figure#module-matplotlib.figure

  是個module,提供了top-level的Artist,The Figure 包括了全部的繪製元素

  還有定義的一些子類

 

Artist class

  abstract base class for objects that render into a FigureCanvas(渲染爲FigureCanvas的對象的抽象基類?#canvas:畫布)

  通常狀況下,figure中的全部可見元素都是Artist的子類

  參考連接:https://matplotlib.org/3.1.1/api/artist_api.html#matplotlib.artist.Artist


Figure:(也是一個類)

  The top level container for all the plot elements

  參考連接:https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure

  有回調函數和事件

  連接裏有這個類的屬性和參數,還有一些方法,添加Artist到figure,添加axes到figure(這種添加方式,若是若是圖中已經有一個帶鍵的軸,那麼它只會使軸成爲當前軸並返回它)還有別的,太長了,沒看下去

 

plot:畫布,

  是畫板的一小部分

 

Axes

  是一個類,包括figure上的大部分figure元素:(Axis、Tick、line2D、Text、polygon...etc,)而且色澤這個座標系,含有事件和回調函數,會在figure中創建一個axes

  參考連接:https://matplotlib.org/3.1.1/api/axes_api.html?highlight=axes#module-matplotlib.axes

  參考連接中還有subplots、plotting

 

Axis

  就是座標軸了:

  參考連接:https://matplotlib.org/3.1.1/api/axis_api.html?highlight=label%20offset#id17(有不少內置類和方法)

  secondary Axis:次要座標軸,就是上面的和右邊的軸

  參考連接:https://matplotlib.org/3.1.1/gallery/subplots_axes_and_figures/secondary_axis.html#sphx-glr-gallery-subplots-axes-and-figures-secondary-axis-py

  介紹了添加次要座標軸的方法,舉了一個例子說明

 

label

  label是座標軸上的標籤,就是tick的文字內容,一條座標軸上能夠有多個labels

  參考連接:https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/barchart.html#sphx-glr-gallery-lines-bars-and-markers-barchart-py

  旋轉label文字方向的:https://matplotlib.org/3.1.1/gallery/ticks_and_spines/ticklabels_rotation.html#sphx-glr-gallery-ticks-and-spines-ticklabels-rotation-py

 

Tick

  是座標軸上的標記  

  參考連接:https://matplotlib.org/3.1.1/api/ticker_api.html#module-matplotlib.ticker

  關於tick的定位和格式,太長了沒看完

 

  matplotlib.pyplot.xticks:獲取或者設置當前x軸上的tick的位置和label

  參考連接:https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.xticks.html#matplotlib.pyplot.xticks

  返回一個包含label位置的數組,一個文字對象列表

 

  plyplot調用(.xticks())(有參和無參)等等同與當前axes調用方法(.get_xticks()和get_xticklabels())

  還能夠Set text labels and properties:

 

  參考連接中還包含ticks能夠完成的工做,用圖直觀的羅列了出來

  Custom Ticker1

  參考連接:https://matplotlib.org/3.1.1/gallery/ticks_and_spines/custom_ticker1.html#sphx-glr-gallery-ticks-and-spines-custom-ticker1-py

  The new ticker code was designed to explicitly support user customized ticking.

  舉了一個例子,經過一個自定義的函數,來自定義ticking

 

matplotlib.projections

  The projection type of the subplot (Axes)

  管理一組可供系統調用的projections(projection:投影)base:object

  參考連接:https://translate.google.cn/?hl=zh-CN&tab=TT#view=home&op=translate&sl=en&tl=zh-CN&text=projections

 

matplotlib.pyplot

  參考連接:https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.html?highlight=pyplot#module-matplotlib.pyplot

  爲matplotlib提供的基類接口,提供像MATLAB那樣的方式來畫圖。主要用來交互式做圖或者程序化做圖的簡單狀況。推薦使用它解決更復雜的plots

 

matplotlib.pyplot.subplot

  在當前figure中add a subplot,返回一個axes

  參考連接:https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.subplot.html

  和Figure.add_subplot()的不一樣

  前者建立一個subplot會刪除 除了交疊邊界 之外與其重疊的 任何已經存在的subplot,而Figure.add_subplot()不會

  後面以圖片的信息展現了許多使用此種方法能夠完成的圖像

 

 matplotlib.pyplot.subplots_adjust

  參考連接:https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.subplots_adjust.html#matplotlib.pyplot.subplots_adjust

  調整這個subplots的佈局

  介紹了默認參數的意思(而且建議使用默認參數)

left = 0.125  #figure 上的subplots的左邊寬度
right = 0.9   # the right side of the subplots of the figure
bottom = 0.1  # the bottom of the subplots of the figure
top = 0.9     # the top of the subplots of the figure
wspace = 0.2  # 在subplots中間保留的高度的量,使用一個axis 高度的分數來表示
hspace = 0.2  # the amount of height reserved for space between subplots,
              # expressed as a fraction of the average axis height

  實際默認值由rc file 控制

 

matplotlib.pyplot.matshow

  參考連接:https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.matshow.html#matplotlib.pyplot.matshow

  在一個新的figure窗口中經過矩陣顯示一個排列(相似像素點的圖像,而不是你想的那樣,連接中又sample)。原點設置在左上角,而且行(array中的第一個維度)垂直排列。figure窗口的縱橫比就是這個array的,除非這樣產生過度短或者狹窄的figure。

 

matplotlib.pyplot.figure

  參考連接:https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.figure.html#matplotlib.pyplot.figure

  creat a new figure

  須要注意的是,若是你須要建立多個figures,確保你明確調用了pyplot.close()對你不使用的figure,由於這樣能確保pyplot正確的從memory中清理

  rcparm定義默認值,這些值能在 matplotlibrc文件中更改

 

matplotlib.pyplot.show

  參考連接:https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.show.html#matplotlib.pyplot.show

  提供了一些畫圖的例子,可是以爲能夠直接看gallery中的

  顯示figure,須要注意的是在非交互模式中,會顯示全部的figure而且block(阻塞?不知道是阻塞或者figure的同位語)直到全部的figure 被關閉。

  而在交互模式中沒有影響,除非你在又非交互模式切換到交互模式以前建立,在這種狀況下,他會致使全部的figure顯示而且不阻塞。

  此外,他還提供了一個實驗性的關鍵字參數:block 來覆蓋上面描述的阻塞行爲。

 

maximize a plt.show()

參考連接:https://stackoverflow.com/questions/12439588/how-to-maximize-a-plt-show-window-using-python

mng=plt.get_current_fig_manager()
mng.window.state('zoomed')
相關文章
相關標籤/搜索