所有带有hist()
的matplotlib examples都会生成一个数据集,将数据集提供给hist
函数,并带有一些二进制数(可能是非均匀间隔),并且该函数会自动计算和然后绘制直方图。
我已经有直方图数据,我只想绘制它,我该怎么做?!例如,我有箱子(半开放范围用方括号和弯曲括号表示),
[0, 1) 0
[1, 2) 3
[2, 3) 8
[3, 4) 6
[4, 5) 2
[5, 6) 3
[6, 7) 1
[7, 8) 0
答案 0 :(得分:11)
也许重量参数对您的问题有帮助。
import matplotlib.pyplot as plt
a= [1,2,3,4,5,6,7,8,9]
b= [5,3,4,5,3,2,1,2,3]
plt.hist(a,9, weights=b)
plt.show()
或者,正如tcaswell所说,你可以制作条形图并改变x轴。
Using matplotlib how could I plot a histogram with given data in python
是一个链接。
答案 1 :(得分:1)
此外,作为替代方案(类似于Matlab),您可以使用dataset = pd.read_csv(r'Documents/clusters.csv')
X = dataset.iloc[:, 1]
X = X.values.reshape(1, -1)
from sklearn.cluster import OPTICS
db = OPTICS(eps=3, min_samples=0).fit(X)
:
$message = "You have been invited to the online meeting '".$schedule->schedule_name.
"', On ".$date." (".$start_time."-".$end_time.") by Tuti.World \n
(See attachments for more details)";
$ical_content = "BEGIN:VCALENDAR
VERSION:2.0
PRODID://Drupal iCal API//EN
BEGIN:VEVENT
UID:http://www.icalmaker.com/event/d8fefcc9-a576-4432-8b20-40e90889affd
DTSTAMP:".$date.
"DTSTART:".$start_time.
"DTEND:".$end_time.
"SUMMARY:Online Meeting
END:VEVENT
END:VCALENDAR";
$mail->msgHTML($message);
$mail->addStringAttachment($ical_content,$file,'base64','text/calendar');
$mail->send();
然后,您还可以添加标题和其他内容,最后保存图像:
bar