122 Likes
qiurisiyu2016
7 years of coding
Follow
matplotlib
1. plt.plot(x,y)
plt.plot(x, y,format_string,**kwargs)?
x-axis data, y-axis data, format_string format string for control curve?
format_string consists of a color character, a style character, and a marker character
import matplotlib.pyplot as plt
plt.plot([1,2,3,6],[4,5,8,1],'g-s ')?
plt.show()
Results
**kwards: ?
color color?
linestyle line style?
marker Marker style?
markerfacecolor Marker color?
markersize Marker size, etc.?
plt.plot([5,4,3,2,1])
plt.show()
Results
plt.plot([20,2,40,6,80]) #Defaults x to [0,1,2,3,4,...].
plt.show()
Results
plt.plot() Parameter Settings
Property Value Type
alpha Controls transparency, with 0 being fully transparent and 1 being opaque
animated [True False]
antialiased or aa [True False]
clip_box a matplotlib.transform.Bbox instance
clip_on [True False]
clip_path a Path instance and a Transform instance, a Patch
color or c color settings
contains the hit testing function
dash_capstyle ['butt ' 'round' 'projecting']
dash_joinstyle ['miter ' 'round' 'bevel']
dashes sequence of on/off ink in points
data data ( np.array xdata, np.array ydata)
figure drawing board object a matplotlib.figure.Figure instance
label diagram
linestyle or ls line style [' -' '-' '-. ':' 'steps' ...]
linewidth or lw width float value in points
lod [True False]
marker data point settings ['+' ',' '.' '1' '2' '3' '4']
markeredgecolor or mec any matplotlib color
markeredgewidth or mew float value in points
markerfacecolor or mfc any matplotlib color p>
markersize or ms float
markevery [ None integer (startind, stride) ]
picker used in interactive line selection
pickradius the line pick selection radius
solid_capstyle ['butt' 'round' ' projecting']
solid_joinstyle ['miter' 'round' 'bevel ']
transform a matplotlib.transforms.Transform instance
visible [True False]
xdata np.array
ydata np. array
zorder any number
determine x, y values, print them out
x=np.linspace(-1,1,5)
y=2*x+1
plt.plot(x,y)
plt.show()
2. plt.figure() is used to draw, customize canvas size
fig1 = plt.figure(num='fig111111', figsize=(10, 3), dpi=75, facecolor='#FFFFFF', edgecolor='#0000FF')
plt.plot(x,y1) ? #Plt.plot operation after variable fig1, graph will be displayed in fig1
fig2 = plt.figure(num='fig222222', figsize=(6, 3), dpi=75, facecolor='#FFFFFF', edgecolor='# FF0000')
plt.plot(x,y2) ? #Plt.plot operation after variable fig2, graph will be displayed in fig2
plt.show()
plt.close()
Results
fig1 = plt.figure(num='fig111111', figsize=(10, 3) , dpi=75, facecolor='#FFFFFF', edgecolor='#0000FF')
plt.plot(x,y1)
plt.plot(x,y2)
fig2 = plt.figure(num='fig222222', figsize=(6, 3), dpi=75, facecolor='#FFFFFF', edgecolor='#FF0000')
plt.show()
plt.close()
Results:
3. plt.subplot(222 )
The size of the canvas will be set by figure into several parts, the parameter '221' that 2 (row) x 2 (colu), that is, the canvas is divided into 2x2, two rows and two columns of the four regions, 1 means that the choice of graphic output in the first region, the graphic output region must be in the parameters of the "line x column" range, here must be selected between 1 and 2 -- if the parameter is set to subplot (111), it means that the entire canvas output, not divided into small areas, graphics output directly on the entire canvas
plt.subplot(222)?
plt.plot(y,xx) #Output the graph in the second area of the 2x2 canvas
plt.show()
plt.subplot(223)? # Output the graph in the third area in the 2x2 canvas
plt.plot(y,xx)
plt.subplot(224)? # Output the graph in the fourth area of the 2x2 canvas
plt.plot(y,xx)
4. plt.xlim set the x-axis or y-axis scale range
such as
plt.xlim(0,1000)? #? set x-axis scale range from 0~1000 #lim is limit, range
plt.ylim(0,20) # set y-axis scale range from 0~20
5, plt.xticks(): set x-axis scale expression
fig2 = plt.figure(num=' fig222222', figsize=(6, 3), dpi=75, facecolor='#FFFFFF', edgecolor='#FF0000')
plt.plot(x,y2)
plt.xticks(np.linspace(0,1000, 15,endpoint=True))? # Set x-axis scale
plt.yticks(np.linspace(0,20,10,endpoint=True))
Results
6. ax2.set_title('xxx') set the title and draw the graph
# Generate [1,2,3,... ,9] sequence
x = np.range(1,10)
y = x
fig = plt.figure()
ax1 = fig.add_subplot(221)
#Set title
ax1.set_title(' Scatter Plot1')
plt.xlabel('M')
plt.ylabel('N')
ax2 = fig.add_subplot(222)
ax2.set_title('Scatter Plot2clf') p>
#Set X axis label
plt.xlabel('X') ? #Setting the X/Y axis label is done after the corresponding figure to correspond to that figure
#Setting the Y axis label
plt.ylabel('Y')
#Drawing a scatterplot
ax1.scatter(x,y,c = 'r',marker = 'o') ? #You can see that drawing a scatterplot is manipulating the figure
ax2.scatter(x,y,c = 'b',marker = 'x')
#Set the icon
plt.legend('show picture x1 ')
#Display the drawn picture
plt.show()
Results
7, plt.hist () plot histogram (can be Gaussian function of these drawings)
plotting can be called matplotlib.pyplot library to carry out, which hist function can be plotted directly on the histogram
call mode:
n, bins, patches = plt.hist(arr, bins=10, normed=0, facecolor='black', edgecolor='black',alpha=1, histtype='bar')
hist has a lot of parameters, but the common ones are these six Only the first one is required, the next four are optional
arr: the one-dimensional array from which the histogram is to be computed
bins: the number of bars in the histogram, optional, defaults to 10
normed: whether or not to normalize the resulting histogram vector. 'barstacked', 'step', 'stepfilled'
Return value :
n: histogram vector. Normalized or not is set by normed
bins: return the interval range of each bin
patches: return the data contained in each bin, it is a list
from skimage import data
import matplotlib. pyplot as plt
img=data.camera()
plt.figure("hist")
arr=img.flatten()
n, bins, patches = plt.hist(arr, bins=256, normed=1,edgecolor normed=1,edgecolor='None',facecolor='red')?
plt.show()
Example:
mu, sigma = 0, .1
s = np.random.normal(loc=mu, scale=sigma, size=1000)
a,b,c = plt.hist(s, bins= 3)
print("a: ",a)
print("b: ",b)
print("c: ",c)
plt.show()
Results:
a:? [ 85. 720. 195.] ? #Value for each column
b:? [-0.36109509 -0.1357318 0.08963149? 0.31499478] #Interval range for each column
c:? <a list of 3 Patch objects> #Total*** how many columns
8. ax1.scatter(x,y,c = 'r',marker = 'o')?
Use note: determine the figure must determine the quadrant, and then use scatter, or do not determine the quadrant, directly use plt.scatter
x = np.arange(1,10)
y = x
fig = plt.figure()
a= plt.subplot() #defaults to one quadrant
# a=fig.add_subplot(222)
a.scatter(x,y,c='r',marker='o')
plt.show()
Results
x = np. arange(1,10)
y = x
plt.scatter(x,y,c='r',marker='o')
plt.show()
Results
import numpy as np
import matplotlib.pyplot as plt
x = np.range(1,10)
y = x
plt.figure()
plt.scatter(x,y,c='r',marker='o')
plt.show ()
Results
Article Knowledge Matches Official Knowledge Archive
Python Introductory Skill Tree Basic Syntax Functions
211242 people are in the process of systematic learning
Open the CSDN APP to see more technical content
Some of plt's Functions in Use_Banana i's Blog_plt Functions
plt.functions Fwuyi's Blog 6513 1plt.figure( ) function: creates a canvas 2plt.plot(x, y, format_string, label="legend name"): plots points and lines, and controls the style. Where x is the x-axis data, y is the y-axis data, and xy is usually a list or array. format_string is the format of the string including the line...
Continue to visit
Python's Data Science Function Package (III)-matplotlib(plt)_hxxjxw's blog...
import matplotlib.pyplot as plt plt.imshow(img) plt.show() plt.imshow() has a cmap parameter, i.e., it specifies the color mapping rules. The default cmap is a ten-color ring, even if it is a single-channel map, the value is between 0 and 1, plt.imshow() can still display the color map, is because the color mapping of the off...
Continue to visit
To Python plt's drawing function detailed
Today, I'd like to share with you a plt's drawing function detailed in Python, with a good reference value, I hope it will be helpful to you. Together, follow the editor over to see it
plt.plot() function details
plt.plot() function details plt.plot(x, y, format_string, **kwargs) Parameters Description x X-axis data, a list or an array, optional y Y-axis data, a list or an array format_ string Format string to control curves, optional **kwargs Second group or more (x,y,format_string) to draw multiple curves format_string Consists of a color character, a style character, and a markup character Color character 'b' blue 'm' magenta magenta 'g' green 'y.
Continue to access the
python image processing basics (plt library function description)_Little Strawberry Daddy's Blog_p...
1.drawing(plt library)1.1 plt.figure(num='',figsize=(x, y),dpi= ,facecolor='',edgecolor= '')num:indicates the title of the whole icon figsize:indicates the size facecolor:indicates 1.2 plt.plot(x,y,format_string,**kwargs)...
Continue to visit
plt's use of some functions_neo3301's blog_plt function
1, plt.plot(x,y) plt.plot(x,y,format_string,**kwargs) x-axis data, y-axis data, format_string control curve The format string format_string consists of color characters, style characters, and markup characters import matplotlib.pyplot as plt ...
Continue visiting
Latest releases python plt plotting explained (plt. version)
Python plt plotting explained
Continue visiting
Basics of Python Image Processing (plt library function descriptions)
import matplotlib. Some basic uses of pyplot as plt, including histograms
Continue visiting
plt.subplot() function analysis_Ensoleile.'s blog_plt.subplot
plt.subplot() function is used to directly formulate the way and location of the division to plot. Function prototype subplot(nrows, ncols, index, **kwargs), generally we only use the first three parameters, the entire plotting area is divided into nrows rows and ncols columns, and index is used for the subplot number.
Continue to visit
... Plt's drawing functions in plt_Ethan's blog's blog_python's plt functions
1、plt.legend plt.legend(loc=0)#Display the position of the legend, adaptive way Description: 'best' : 0, (only implemented for axes legends)(self-adaptive way) 'upper' : 0, (only implemented for axes legends)(self-adaptive way) 'upper' : 0, (only implemented for axes legends)(self-adaptive way) 'upper' : 1, (only implemented for axes legends)(self-adaptive way) adaptive mode) 'upper right' : 1, 'upper left' : 2, 'lower left' : 3, 'lower right' : 4, ...
Continue to visit
plt.functions
1 plt.figure( ) function: creates the canvas 2 plt.plot(x, y, format_string, label="legend_name"): plots points and lines, and controls the style. Where x is the x-axis data, y is the y-axis data, xy is generally lists and arrays. format_string is a string format including line color, point type, line type of three parts. Pass the legend name to the parameter label and use plt.legend( ) to create the legend. 2.1 Draw a line containing x and y import matplotlib.pyplot as plt x = [1, 2, 3, 4] y
Continue to visit
Basic use of the plt drawing tool for getting started with deep learning in Python (detailed annotations, super easy)
Python comes with plt, which is one of the most commonly used deep learning One of the most commonly used libraries, in the publication of the article must have a map as a support, plt for deep learning one of the necessary skills. As a deep learning beginner, only need to master some basic drawing operations can be, and other such as to be used when you look at the function API on the line. 1 import plt library (long name, a little difficult to remember) import matplotlib.pyplot as plt First, draw a random map, save it to try the water: plt.figure(figsize=(12,8), dpi=80) plt.plot([1,2,6,4],[4,5,6,9]) plt. savefig('. /plt_pn
Continue to visit
python drawing plt function to learn_dlut_yan's blog_python plt
figure() function helps us to generate multiple plots at the same time to deal with the processing, while the subplot() function is used to realize that, in a large picture, there are multiple small subplots. Processing which figure, then select which figure, and then draw. Refer to the blog importmatplotlib.pyplotaspltimportnumpyasnp x=np.arange(-1,1,0.1...
Continue visiting
plt.plot() function_Anziol's blog_plt.plot() function
plt.plot() function is matplotlib.pyplot used to draw the function to pass a list of values:import numpy as npimport matplotlib.pyplot as pltt=[1,2,3,4,5]y=[3,4,5,6,7]plt.plot(t, y) when x is omitted, default [0,1...,N-1] incremental can be passed tuple can also be passed...
Continue to visit
Python drawing plt function to learn
Drawing tools in python : matplotli, specialized in drawing graphs. I. Installation and Import Toolkit Installation: conda install matplotli Import: import matplotlib.pyplot as plt Drawing mainly: list plotting; multi-plot plotting; array plotting II. List plotting 1. Basic plotting: plt.plot; plt.show import matplotlib.pyplot as plt x = [1, 2, 3, 4] y = [1, 4, 9, 16] plt.plot(x, y) plt.show()
Continue to visit
Plt in Python meaning_of_plt_drawing_functions_in_Python_detailed
1, plt.legendplt.legend(loc=0)#show_position_of_the_legend_in_adaptive_mode description: 'best' : 0, (only implemented for axes legends) (adaptive mode) 'upper right' : 1, 'upper left' : 2, 'lower left' : 3, 'lower right' : 4, 'right' : 5, 'cent...
Continue to visit
Basic usage of the plt plot package in Python
In this case, the first two input parameters represent the coordinates of the x-axis and the y-axis, and the plot function connects the supplied coordinate points, i.e., it becomes the line type of each style to be plotted. Commonly used parameters, figsize need a tuple value, indicating the ratio of the horizontal and vertical coordinates of the blank canvas; plt.xticks() and plt.yticks() functions are used to set the step and scale of the axis. plt.xlabel(), plt.ylabel() and plt.title() functions are used to set the x axis, y axis and the title information of the icon, respectively. and title information for the icon. The data processing, found their understanding of plt and the lack of use, so some basic usage of the study, to facilitate the use of their own after, without the need for frequent access to information....
Continue visiting
python-plt.xticks vs plt.yticks
Chestnut: plt.figure(figuresize=(10, 10)) for i in range(25): plt.subplot(5, 5, i+1) plt.xticks( []) plt.yticks([]) plt.grid(False) plt.imshow(train_images[i], cmap=plt.cm.binary) plt.xlabel(class_names[train_labels[i]]) plt.show() set x or y axis corresponds to show
Continue visit
plt plot summary
matplotlib plot
Continue visit
Data Science Functions Package for Python (III) - matplotlib(plt)
/skyerhxx/01-/tree/master/%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE
Continue to visit
Hot picks for python plt drawing graphs
Using csv data files on baidu.com import pandas as pd unrate = pd.read_csv('unrate.csv') # pd.to_datetime() convert to date format, i.e. from 1948/1/1 to 1948-01-01 unrate['DATE'] = pd.to_datetime(unrate[' DATE']) print(unrate.head(12)) ...
Continue to visit
Python data visualization implementation steps, Python data visualization map implementation process explained
Python data visualization map implementation process explained more python video tutorials please go to the rookie tutorials/python drawing distribution map code example: # encoding=utf- 8import matplotlib.pyplot as pltfrom pylab import * # Support Chinese mpl.rcParams['font.sans-serif'] = ['SimHei ']'mention...
Continue visiting
matplotlib-plt.plot Usage
Article Contents For those who are good at English, refer directly to this site matplotlib.pyplot.plot(*args, scalex=True, scaley=True, data=None, ** kwargs) Plot x,y as lines or markers Parameters: x, y: Horizontal/vertical coordinates of the data points. x values are optional and default to range(len(y)). Typically, these parameters are one-dimensional arrays. They can also be scalar or two-dimensional (in which case the columns represent separate data sets). These parameters cannot be passed as keywords. fmt: format string, the format string is just an indentation used to quickly set basic row properties
Continue to visit
Python Plt Learning
A simple study of plt
Continue to visit
Difference between plt.show() and plt.imshow()
Question: plt.imshow() cannot display the image Solution:Add: plt.show(), i.e. plt.imshow(image) #image indicates the image to be processed plt.show() Principle: plt.imshow() function is responsible for processing the image and displaying the formatting of it, while plt.show() takes the plt. .imshow() function displays the processed function. ...
Continue visiting
python question bank brush site_python online brush site
{"moduleinfo":{"card_count":[{"count_phone":1, "count":1}], "search_count":[{" count_phone":4, "count":4}]}, "card":[{"des": "The largest platform for Ali technicians to release original technical content to the outside world; the community covers nine major technical areas: cloud computing, big data, artificial intelligence, IoT, cloud native, database, microservices, security, development and operations and maintenance." , "link1":...
Continue visiting
python xticks_Python Matplotlib.pyplot.yticks() Usage and Code Examples
Matplotlib is a library in Python, which is a mathematical extension to the Numeral's-NumPy library. Pyplot is a state-based interface to the Matplotlib module, which provides MATLAB-like interfaces.Matplotlib.pyplot.yticks() functionThe annotate() function in the pyplot module of the matplotlib library is used to get and set the current tick position and labels of the y-axis. Usage: matplotlib.pyplot.yticks...
Continue to visit
Python's plt function _plt.plot drawing function
/u010358304/article/details/78906768plt.rcParams['font.sans-serif ']=['SimHei'] plt.rcParams['axes.unicode_minus'] = False#Set the name of the horizontal and vertical coordinates and the corresponding font Format font1 = {'weight' : 'normal', 'size' : 15,...
Continue visiting
plt functions
Write a comment
7
794
122