惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 溺水妖精

连载暂时停止,因为要打官司^^在这里谢谢各位的支持啦! 徒给别人做嫁衣——与人共同创业(1) 好久没来了^^来看看,顺便整理一下我这几年的经历 那年的那一场雪 写给未来的孩子-----孩子不要怨恨,不要气馁,每个人都有自己的无奈,每个人都有受伤的时候,学会宽容,学会忍耐,学会善待自己和他人..... 好久没来写什么东西了:(鄙视下自己~~ 打开一个应用程序~~ - 溺水妖精 - 博客园 学习笔记1 5555~~~晕了晕了~~~object类型的相等问题~~~ - 溺水妖精 - 博客园 刚才在博客堂看到的:( 今天从HELLO,WORLD开始! 55555555~~今天夸下海口,不学C#都不行了~~ 最近好倒霉哦!!!!!!!555555555555555555555555 今天是妇女节,一定要去采购,女人用的东西都打折:) 蓝冰 MYSQL和MSSQL修改密码总结----在此感谢一直帮助我的J9988大叔 一个男人的话 随想----真的是断翼天使~~ 周末了,好幸福哦!!!HOHO~~~~~~~~~~~~~~~~~~~~~
下午没有什么事情,就做了个数值统计直方图,好玩,哈
溺水妖精 · 2004-03-08 · via 博客园 - 溺水妖精

    如果经理看到我工作时间做其他的非要气死不可
    最近不知怎的,和GD2较上劲了,喜欢上用他画图玩了,哈~~

    其实做直方图,就是计算坐标,除此之外没有什么难的。
    而我笨笨的认为象X、Y一样,下面的数值小,上面的大结果发现自己脑袋坏掉了,图片也好、屏幕也好,都是左上角为原点的。
   
    这个就是我做出来的图,有点垃圾,嘿嘿,偶是没有美感啦,不然就去做美工了。。。

以下是代码:

   //在图中表示的统计分析数字,目前最多只能分析5组数居(在实际应用中,可以用百分比算)
$values=array(100,300,120,77,230);
Header("Content-type: image/gif");
$im = imagecreate(400,400);
//颜色
$WHITE=ImageColorAllocate($im, 250,250,250);
$black=ImageColorAllocate($im, 0,0,0);
$grey=ImageColorAllocate($im, 150,150,150);
$Blue=imagecolorallocate($im, 184, 212, 250);
$Red=imagecolorallocate($im, 255, 0, 0);
//原点坐标
$min=array(50,350);
//最大点坐标
$max=array(350,50);
//柱体的间隔距离
$space=20;
//柱体的宽度
$weith=30;

ImageRectangle($im,$min[0],$min[1],$max[0],$max[1],$grey);
//画格线并在左侧写出相应的数值
for($i=1;$i<10;$i+=1){
   $y=$i*30;
   imagestring($im,5,$min[0]-35,$min[1]-$y,$y,$black);
   ImageLine($im,$min[0]+$y,$min[1],$min[0]+$y,$max[1],$grey);
   ImageLine($im,$min[0],$max[1]+$y,$max[0],$max[1]+$y,$grey);
}
imagestring($im,5,$min[0]-35,$min[1]-$y-30,$y+30,$black);

//根据数字绘制直方图
for($i=0;$i<5;$i++){
   $y=10+$i*60;
   imagefilledrectangle($im,($min[0]+$space),($min[1]-$values[$i]),($min[0]+$weith+$space+7),$min[1]-1,$grey);
   imagefilledrectangle($im,($min[0]+$space),($min[1]-$values[$i]+1),($min[0]+$weith+$space),$min[1]-1,$Blue);
   imagestring($im,5,$min[0]+$y,$min[1]+10,"200".$i."Y",$Red);
   $space=$space+$weith+30;
}

ImagePNG($im);
ImageDestroy($im);