Learn the "father and child Programming Journey" Chapter 16, with the example of the book to learn, learned to draw a circle, I found a way to draw the line, so you can draw the Japanese flag on screen:Hand animation is not good to see, you can also do not manually draw, directly draw lines:The code is as follows:1 Import Pygame,sys2 fromPygame.locals Import *3 Print Pygame.ver4 Pygame.init ()5Screen = Pygame.display.set_mode ([640,480])6Color= ( $,156, -) 7points=[] 8Screen.fill ([255,255,255
Python implements the method of drawing a straight line cursor between two coordinate axes in matplotlib
This example describes how to draw a straight line cursor between two coordinate axes in matplotlib using Python. Share it with you for your reference. The details are as follows:
Let's take a look at the examples and effects below.
?
1 2 3 4 5 6
When using matplotlib drawing to add a formula to a picture, it is generally necessary to use the text or annotate function, combined with latex grammar ' $...$ '.For fractions, if you use \frac{}{} directly, the characters on the numerator denominator are small, as shown in the Green formula.To solve this problem, we need to use the \displaystyle, that is, using the ' $\displaystyle ... $ ', as shown in the Blue formula in the effect. However, the pr
Into the Python drawing pitStart machine learning today.Learn about the 10,000 functions of matplotlib,numpy and scipy in a hurry.This is Matplotlib's official website.Let me hooves a little bit.ImportNumPy as NPImportMatplotlib.pyplot as Pltx= Np.linspace (0, 10, 1000) y=np.sin (x) z= Np.cos (x**2) plt.figure (figsize= (8,4)) Plt.plot (X,y,label="$sin (x) $", color="Red", linewidth=2) Plt.plot (X,z,"b--",
occupy different storage spaces), while Chinese characters convert 1 Unicode characters into 3 UTF-8 characters, and you see \xe4 is one of the bytes, because its value is 228 , no corresponding letter can be displayed, so the numeric value of the byte is displayed in hexadecimal. len () function can return the length of a string: >>> len (U ' abc ') 3>>> len (' abc ') 3>>> len (U ' Chinese ') 2>> > Len (' \xe4\xb8\xad\xe6\x96\x87 ') 6 in turn, the UTF-8 code represents the string ' xxx '
A total of 6 kinds of library recommended, strongly recommend requests library.
One of the Web libraries: Httplib Library
#!/usr/bin/env python
#coding =utf8
import httplib
httpclient = None
try:
httpclient = Httplib. Httpconnection (' www.baidu.com ', timeout=30)
httpclient.request (' Get ', '/')
#res
Drawing intuitively, it is essential to further select a time series analysis model, in order to show more clearly the regularity of the timing data (including the trend, the regularity of the change (one week, one months, one year, and so on) and the periodic pattern. The following is mainly based on the pandas library summarizes what common diagrams can be used for analysis. There are a total of the follo
window when it is created using figure (number_or_name) or it can B E a figure instance fig obtained, i.e., Usingfig = figure (). If no argument is given to close (), the currently active window would be closed. Furthermore, there is the syntax close ("All"), which closes all figures.http://www.ibm.com/developerworks/ Cn/linux/l-matplotlib/index.html There are a lot of things to learn here too http://www.w3school.com.cn/xmldom/dom_element.asp In fact, no matter what the language, the structure
value_key_pairs[-N:]print(top_counts ( Counts)# Method 2counts = Counter (time_zones) Counts.most_common (ten) Print (Counts.most_common (10))5) Use Pandas to simplify, count the time zone, and give the Top ten bar chart#use Pandas to count time zones fromPandasImportDataFrameImportPandas as PDImportNumPy as Npframe=DataFrame (Records)#print (frame)#tz_counts = frame["TZ"].value_counts ()#print (Tz_counts[:10])Clean_tz = frame["TZ"].fillna ("missing")#Missing value handlingClean_tz[clean_tz = =
First, you enter the weights for edges and edges, and then you draw the node position. Dividing real and imaginary edges by weight size#coding: utf-8#!/usr/bin/env python "" "An example using Graph as a weighted network." " __author__ = "" "Aric Hagberg ([emailprotected])" "" Try:import Matplotlib.pyplot as Pltexcept:raiseimport netw Orkx as Nxg=nx. Graph () #加入带权边G. Add_edge (' A ', ' B ', weight=0.6) G.add_edge (' A ', ' C ', weight=0.2) G.add_edge
With Python's turtle module you can draw a lot of beautiful graphics, the following is a brief introduction to how to use.The tool that needs to be used has Python,python installation here is no longer elaborate. Search by yourself.1 fromTurtleImport*#Introducing the Turtle module2Color'Red','Yellow')#set the color and fill color of the drawing3 4 #Turtle Settings5Hideturtle ()#Hide Arrows6Speed (10)#Set S
effects.fontscale– font size, this value is multiplied by the font built-in size to get the font sizecolor– text colorthickness– the thickness of the line, similar to the 0.38 nib and the 0.5 niblinetype– linear.Bottomleftorigin–true, the image data origin is in the lower left corner. Otherwise, the image data origin is in the upper left corner.Case codeImportNumPy asNpImportCv2img=Np.zeros (( +, +,3), np.uint8) Cv2.line (IMG, (0,0),(511,511),(255,0,0),5) Cv2.rectangle (IMG, (384,0),(510, -),(0
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.