SoFunction
Updated on 2024-10-30

Example of python plotting distribution line graphs

To plot a distribution (line) graph in Python, the plot() function is used.

A simple example:

# encoding=utf-8
import  as plt
from pylab import * # Support Chinese

['-serif'] = ['SimHei']
# 'mentioned0cluster',
names = ['mentioned1cluster','mentioned2cluster', 'mentioned3cluster', 'mentioned4cluster', 'mentioned5cluster', 'mentioned6cluster', 'mentioned7cluster', 'mentioned8cluster', 'mentioned9cluster', 'mentioned10cluster']
x = range(len(names))
# y_0625 = [39266,56796,42996,24872,13849,8609,5331,1971,554,169,26]

y_0626_1=[4793,100,0,0,0,0,0,0,0,0]
# y_0626_2=[2622,203,0,0,0,0,0,0,0,0,0]

# (x, y, 'ro-')
# (x, y1, 'bo-')
# (-1, 11) # Limit the range of the horizontal axis
# (-1, 110) # Limit the range of the vertical axis
(x, y_0626_1, marker='o', mec='r', mfc='w', label='HighRating:MentionedClusterNum Distribution')
# (x, y_0626_2, marker='o', mec='r', mfc='w', label='LowRating:MentionedClusterNum Distribution')
# (x, y1, marker='*', ms=10, label=u'y=x^3 graph')
() # Give effect to the legend
(x, names, rotation=45)
(0)
plt.subplots_adjust(bottom=0.15)
# (u "time(s) neighbors") # X-axis labels
("clusters")
("number of reviews") # Y-axis labels
("A simple plot") # Title

()

Results:

Above is python draw distribution line graph sample code details, more information about python draw distribution line graph please pay attention to my other related articles!