In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to use the Python matplotlib Line2D object, the article is very detailed, has a certain reference value, interested friends must read it!
Summary
Matplotlib.pyplot is a lot like MATLAB. Each of its functions makes changes to existing graphics: for example, creating a figure, creating a drawing area, making lines in the drawing area, and decorating it with tags.
If you pass in a simple list or array,matplotlib, it will be treated as a y value and will automatically generate an x value. Virtually all sequences are converted to numpy arrays.
Import matplotlib.pyplot as pltplt.plot ([1, 2, 3, 4]) plt.ylabel ('some numbers') plt.show ()
When you pass in two list or array, the first is treated as an x value, the second as a y value, and you can set the shape and color of the display through the third parameter (this is a combination), of course, you can also set the shape and color separately. You can set the maximum and minimum values of the x-axis and y-axis through the plt.axis (xmin, xmax, ymin, ymax) function:
Import matplotlib.pyplot as pltplt.plot ([1, 2, 3, 4], [1, 4, 9, 16], 'ro') plt.axis ([0,6,0,20]) plt.show ()
Line2D object Line2DBases: matplotlib.artist.Artistclass matplotlib.lines.Line2D (xdata, ydata, linewidth=None, linestyle=None, color=None, marker=None, markersize=None, markeredgewidth=None, markeredgecolor=None, markerfacecolor=None, markerfacecoloralt='none', fillstyle=None, antialiased=None, dash_capstyle=None, solid_capstyle=None, dash_joinstyle=None, solid_joinstyle=None, pickradius=5, drawstyle=None, markevery=None, * * kwargs) attribute control
There are three ways to set the properties of a line
1) set it directly in the plot () function
Plt.plot (x, y, linewidth=2.0)
2) set the line object by obtaining the line object
Line, = plt.plot (x, y,'-') line.set_antialiased (False) # turn off antialising
3) get the line attribute and set it using the setp () function
Lines = plt.plot (x1, y1, x2, y2) # use keyword argsplt.setp (lines, color='r', linewidth=2.0) PropertyValue Typealphafloatanimated [True False] antialiased or aa [True False] clip_boxa matplotlib.transform.Bbox instanceclip_ on [true False] clip_patha Path instance and a Transform instance, a Patchcolor or cany matplotlib colorcontainsthe hit testing functiondash_capstyle ['butt'' round' 'projecting'] dash_joinstyle [' miter' 'round'' bevel'] dashessequence of on/off ink in pointsdata (np.array xdata Np.array ydata) figurea matplotlib.figure.Figure instancelabelany stringlinestyle or ls ['-.':''steps'...] Linewidth or lwfloat value in pointslod [True False] marker ['+','.'1''2''3' 4'] markeredgecolor or mecany matplotlib colormarkeredgewidth or mewfloat value in pointsmarkerfacecolor or mfcany matplotlib colormarkersize or msfloatmarkevery [None integer (startind) Stride)] pickerused in interactive line selectionpickradiusthe line pick selection radiussolid_capstyle ['butt'' round' 'projecting'] solid_joinstyle [' miter' 'round'' bevel'] transforma matplotlib.transforms.Transform instancevisible [True False] xdatanp.arrayydatanp.arrayzorderany numberlinestyledescription'-'?or?'solid'solid line'-'?or?'dashed'dashed line'-.'?or?'dashdot'dash-dotted line':'?or?'dotted'dotted line'None'draw nothing'?'draw nothing "draw nothingmarkerdescription". "point" "pixel" o "circle" v "triangle_down" ^ "triangle_up"triangle_right" 1 "tri_down" 2 "tri_up" 3 "tri_left" 4 "tri_right" 8 "octagon" s "square" p "pentagon" P "plus (filled)" * "star" h "hexagon1" H "hexagon2" + "plus" x "X" x (filled) "D" diamond "d thin_diamond"_" hlineTICKLEFTtickleftTICKRIGHTtickrightTICKUPtickupTICKDOWNtickdownCARETLEFTcaretleft (centered at tip) CARETRIGHTcaretright (centered at tip) CARETUPcaretup (centered at tip) CARETDOWNcaretdown (centered at tip) CARETLEFTBASEcaretleft (centered at base) CARETRIGHTBASEcaretright (centered at base) CARETUPBASEcaretup (centered at base) "None" ? or? "nothing'. 'render the string using mathtext.vertsa list of (x, y) pairs used for Path vertices. The center of the marker is located at (0Pol 0) and the size is normalized.patha?Path?instance. These are all the contents of the article "how to use Python matplotlib Line2D objects". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.