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 = =
Work needs to observe the trend of data changes, with Python to write a small program to display simple charts, to share the convenience of people with the same needs, matplotlib is a very good library.#!encode=utf8 fromMatplotlibImportPyplot as PltImportSysignore_num= (int) (sys.argv[1]) Data=sys.argv[2]show_type=0ifLen (SYS.ARGV) >3: Show_type= (int) (sys.argv[3]) x=[]valid_ppl=[]train_ll=[]valid_ll=[]fi=open (data,"R") Line=Fi.readline () n=0 while
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
python drawing--Columnar chart
On the basis of the previous (Python drawing-simple start and line chart), let's draw a bar chart
There are two kinds of columnar graphs (one for histogram and the other for bar chart) One, bar chart
The main methods are:
Atplotlib.pyplot.bar (left, height, width=0.8, Bottom=none, Hold=
Today is too late, refer to the link first put here, tomorrow, according to their actual situation as a whole, http://www.cnblogs.com/qianlifeng/archive/2012/02/13/2350086.htmlActually encountered the source code as an example affixed.# Show your cluster only available with 2-d data#centroids为k个类别, which holds the centroid of each category#clusterAssment为样本的标记, the first column is the category number for this sample, and the second is the distance to the centroid of this category def showcluster
), need to determine the two points of the rectangle (upper left and bottom right), color, the type of line (not set to default). For example: import cv2importas npfromimportas pltimg = np.zeros((512,512,3),np.uint8)#生成一个空彩色图像cv2.rectangle(img,(20,20),(411,411),(55,255,155),5)plt.imshow(img,‘brg‘)(iii) Draw roundIt is also simple to draw a circle, just to determine the center and radius, the function:Cv2.circle (IMG, (380,0), 63, (255,0,0), 3), such as:import cv2importas npfromimportas pltimg =
First, the weights of the edges and edges are entered, then the node positions are drawn, and the real and imaginary edges are divided according to the weight size. Copyright NOTICE: Welcome reprint, Reprint please indicate the source http://blog.csdn.net/ztf312/ Python-networkx: Drawing According to the weight of the graph
), the two points of the rectangle (upper-left corner and lower-right corner) need to be determined. Color, the type of line (not set to default). For example: import cv2importas npfromimportas pltimg = np.zeros((512,512,3),np.uint8)#生成一个空彩色图像cv2.rectangle(img,(20,20),(411,411),(55,255,155),5)plt.imshow(img,‘brg‘)(iii) Draw roundDrawing a circle is also very easy, just need to determine the center and radius, function:Cv2.circle (IMG, (380,0), 63, (255,0,0), 3), for example:import cv2importas n
randomly generate a set chart, with the path attribute, the figure size 1*1, find the closest node from the center [0.5, 0.5], and follow the path staining.
networkx Examples? Drawing? Random Geometric Graph
Copyright NOTICE: Welcome reprint, Reprint please indicate the source http://blog.csdn.net/ztf312/
To facilitate the search and use of Python matplotlib the appropriate drawing settings interface, the common settings are written in the same code for easy reference, including:1. Setting of Chinese and special characters2, sub-chart, title, legend settings3, the name of the axis, scale, spacing and other settings4, the color of the line, style, width of the settingsCode GitHub Links: (to be added)#-*-codin
This example describes the Python drawing method. Share to everyone for your reference. Specific as follows:
#-*-Coding:utf-8-*-import Matplotlib.pyplot as Pltdef main (): # Color list colorlist = [' B ', ' G ', ' R ', ' C ', ' m ', ' y ', ' k ' ] # Common horizontal threadlist = [1,2,4,8,10] # Set the horizontal and ordinate names plt.xlabel (' Threads ') Plt.ylabel (' Concurrent ') # g
ImportMatplotlib.pyplot as Plt#The slices would be ordered and plotted counter-clockwise.Labels ='Frogs','Hogs','Dogs','Logs'Sizes= [15, 30, 45, 10]colors= ['Yellowgreen','Gold','Lightskyblue','lightcoral']explode= (0, 0.1, 0, 0)#Only "Explode" the 2nd slice (i.e. ' hogs ')Plt.pie (sizes, explode=explode, Labels=labels, colors=colors,autopct='%1.1f%%', Shadow=true, startangle=90)#Set aspect ratio to being equal so, pie is drawn as a circle.Plt.axis ('Equal') Plt.savefig ('D:\\pie.png') plt.show
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.