phplot生成图片类用法详解
这篇文章主要介绍了phplot生成图片类用法,较为详细的分析了phplot生成图片类常用函数的用法及生成图片的完整实例,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了phplot生成图片类用法。分享给大家供大家参考。具体分析如下:
phplot是一个利用php的图象函数编写的一个自动生成类,首先申明一下,我对他也只是了解. 在原来的有些版本好象还需要多方面的配置和支持,不过现在都用的是php5系列了,大家只要了解一些常用到的函数,就比如我们学习一种软件一样,只需要懂得怎样使用他就可以了,如果感兴趣的朋友可以深入的学习学习,不过对于我们大多数的朋友来说,只要会使用他就可以了,毕竟也不是常用,只是需要用php作图的时候才用到他。所以我们只需要知道他怎么用就可以了,那么就必须知道他的函数的作用,好比我们学习discuz一样,要懂得怎么用他就可以了!
phplot的下载地址是
也可以从此处本站下载:
他的常用函数分为几个类:配置函数,显示函数,颜色函数.
1.配置函数:配置phplot使用什么样的类型,以及以什么样的方式显示图象。
a.SetDataType($which_dt):设定使用的数据类型,在这个里面可以使用多种类型。
(1)text-date:数据沿着x柱,等间距排行。每个数组元素代表x轴上的某一位置的点,他同时也是数组,第一个元素代表x坐标,后面的所有元素都代表y坐标。
(2) data-data:与上面的类型相似,不同的是数值数组的第二个元素代表x坐标,后面的代表y坐标,而第一个元素仅仅是一个标签。
(3)data-data-error:与data-data类似,不同的是他的数值数组后面还有两个元素代表error_plus和error_minus,如
(data_labl,x_position,y_position,error_plus,error_minus).
b.SetDataValues($which_dv):把一个数组$which_dv赋给类的一个变量$this->data_values.这个函数要开始作图之前调用。
c.SetPlotType($which_pt):设定图表的类型,可以是bars,lines,linepoints,area,points,pie等。
d.SetErrorBarLineWidth($wd):设定错误栏的宽度。
e.SetFileFormat($which_file_format):设定输出的图象文件的格式,可以是GIF,PNG,JPEG等。还有要看你的GD库是否支持。
f.SetUseTTF($which_ttf):设定是否使用TTF,如果编译php支持TTF,就使用SetUseTTF("1");否则设置为0.
2.显示函数:显示图象设定输出图表所使用的线条的类型,宽度等参量,还可以设定坐标轴刻度的间距,图表的大小等。
a.SetErrorBarShape($which_ebs):设定精度线的类型,可以是line或者是tee,如果是tee,则T型线的半度设定为SetErrorBarSize.
b.SetErrprBarSize($which_ebs):设置精度线的宽度。
c.SetHorizTickIncreament($which_ti):设定x轴的显示刻度的间距。
d.SetHorizTicks($whick_nt):设定x轴显示刻度的个数。(不能和SetHorizTickIncreament)
e.SetNumVertTicks($which_nt):设定x轴显示刻度的个数。(不能和SetVertTickIncreament)
f.SetPlotArearpixels($x1,$y1,$x2,$y2):设定图表大小。
g.SetPointShape($which_pt):设置定点的形状:rect,circle,diamond,triangle,dot,line,halfline.
h.SetPointSize($whick_ps教程):设定点的宽度。
i.SetPrecisionX($whick_prec):设定x轴的精度。$whick_prec代表小数点后面数字的个数。
j.SetPrecisiony($whick_prec)设定y轴的精度。$whick_prec代表小数点后面数字的个数。
k.SetSjading($whick_s):设定阴影的宽度。
l.SetTickLength($which_tl):设定坐标轴上的标记线的长度,单位为pixel.
m.SetTile($title):设定图表的标题。
n.SetVertTickIncreament($whick_ti):和SetHorizTicks($whick_nt)这两个函数用于设定坐标轴上标记线的垂直和水平间隔。
o.SetXDataLabelMaxlength($which_xdlm):设定x轴上的标签的最大长度。
p.SetXGridLabelType($which_xtf):设定x轴的标签类型,可以是time,title,data,none或者default.
(1).time:由函数strftime()设定。
(2).title:文本类型。
(3).data:用函数number_format()格式化数字。
(4).none:没有任何标签。
(5).default:按照输入的形式输出.
3.颜色函数:颜色函数用于设定图表中的各元素的显示颜色,包括图象背景颜色,删格线的颜色,,标题颜色等!
a.SetBackgroundColor($which_color):设定整个图象的背景颜色。
b.SetGridColor($which_color):设定删格线的颜色。
c.SetLegend($which_legend):参数是一个文本数组,他的内容显示在一个图列框中。
d.SetLegendPixels($which_x,$which_y,$which_type):设定图列框左下角点的坐标,最后一个参数以后可用。
e.SetLightGridColor($which_color):删割线线有两种颜色,这个函数设定其中的一种。
f.SetLineWidth($which_lt):设定图表中使用的线宽,他也影响精度线的宽度。
g.SetLineStyles($which_sls):设定线条的类型,可以是实线或者虚线。
h.SetPlotBgColor($which_color):设定使用SetPlotAreaPixels()函数设定的区域的颜色。
i.SetTextColor($which_color):设定文本的颜色,默认是黑色。
j.SetTickColor($which_color):设定坐标轴上刻线的颜色。
k.SetTitleColor($which_color):设定标题颜色。
看个实例,生成上面图形的代码如下:
复制代码 代码如下:
# PHPlot Demo
# 2008-01-09 ljb
# For more information see
# Load the PHPlot class library:
require_once 'phplot.php';
# Define the data array: Label, the 3 data sets.
# Year, Features, Bugs, Happy Users:
$data = array(
array('2001', 60, 35, 20),
array('2002', 65, 30, 30),
array('2003', 70, 25, 40),
array('2004', 72, 20, 60),
array('2005', 75, 15, 70),
array('2006', 77, 10, 80),
array('2007', 80, 5, 90),
);
# Create a PHPlot object which will make a 600x400 pixel image:
$p = new PHPlot(600, 400);
# Use TrueType fonts:
$p->SetDefaultTTFont('./arial.ttf');
# Set the main plot title:
$p->SetTitle('PHPlot Customer Satisfaction (estimated)');
# Select the data array representation and store the data:
$p->SetDataType('text-data');
$p->SetDataValues($data);
# Select the plot type - bar chart:
$p->SetPlotType('bars');
# Define the data range. PHPlot can do this automatically, but not as well.
$p->SetPlotAreaWorld(0, 0, 7, 100);
# Select an overall image background color and another color under the plot:
$p->SetBackgroundColor('#ffffcc');
$p->SetDrawPlotAreaBackground(True);
$p->SetPlotBgColor('#ffffff');
# Draw lines on all 4 sides of the plot:
$p->SetPlotBorderType('full');
# Set a 3 line legend, and position it in the upper left corner:
$p->SetLegend(array('Features', 'Bugs', 'Happy Users'));
$p->SetLegendWorld(0.1, 95);
# Turn data labels on, and all ticks and tick labels off:
$p->SetXDataLabelPos('plotdown');
$p->SetXTickPos('none');
$p->SetXTickLabelPos('none');
$p->SetYTickPos('none');
$p->SetYTickLabelPos('none');
# Generate and output the graph now:
$p->DrawGraph();
希望本文所述对大家的php程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



With the continuous development of social media, Xiaohongshu has become a platform for more and more young people to share their lives and discover beautiful things. Many users are troubled by auto-save issues when posting images. So, how to solve this problem? 1. How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? 1. Clear the cache First, we can try to clear the cache data of Xiaohongshu. The steps are as follows: (1) Open Xiaohongshu and click the "My" button in the lower right corner; (2) On the personal center page, find "Settings" and click it; (3) Scroll down and find the "Clear Cache" option. Click OK. After clearing the cache, re-enter Xiaohongshu and try to post pictures to see if the automatic saving problem is solved. 2. Update the Xiaohongshu version to ensure that your Xiaohongshu

With the popularity of Douyin short videos, user interactions in the comment area have become more colorful. Some users wish to share images in comments to better express their opinions or emotions. So, how to post pictures in TikTok comments? This article will answer this question in detail and provide you with some related tips and precautions. 1. How to post pictures in Douyin comments? 1. Open Douyin: First, you need to open Douyin APP and log in to your account. 2. Find the comment area: When browsing or posting a short video, find the place where you want to comment and click the "Comment" button. 3. Enter your comment content: Enter your comment content in the comment area. 4. Choose to send a picture: In the interface for entering comment content, you will see a "picture" button or a "+" button, click

Apple's recent iPhones capture memories with crisp detail, saturation and brightness. But sometimes, you may encounter some issues that may cause the image to look less clear. While autofocus on iPhone cameras has come a long way, allowing you to take photos quickly, the camera can mistakenly focus on the wrong subject in certain situations, making the photo blurry in unwanted areas. If your photos on your iPhone look out of focus or lack sharpness overall, the following post should help you make them sharper. How to Make Pictures Clearer on iPhone [6 Methods] You can try using the native Photos app to clean up your photos. If you want more features and options

In PowerPoint, it is a common technique to display pictures one by one, which can be achieved by setting animation effects. This guide details the steps to implement this technique, including basic setup, image insertion, adding animation, and adjusting animation order and timing. Additionally, advanced settings and adjustments are provided, such as using triggers, adjusting animation speed and order, and previewing animation effects. By following these steps and tips, users can easily set up pictures to appear one after another in PowerPoint, thereby enhancing the visual impact of the presentation and grabbing the attention of the audience.

Some netizens found that when they opened the browser web page, the pictures on the web page could not be loaded for a long time. What happened? I checked that the network is normal, so where is the problem? The editor below will introduce to you six solutions to the problem that web page images cannot be loaded. Web page images cannot be loaded: 1. Internet speed problem The web page cannot display images. It may be because the computer's Internet speed is relatively slow and there are more softwares opened on the computer. And the images we access are relatively large, which may be due to loading timeout. As a result, the picture cannot be displayed. You can turn off the software that consumes more network speed. You can go to the task manager to check. 2. Too many visitors. If the webpage cannot display pictures, it may be because the webpages we visited were visited at the same time.

Are you also using Foxit PDF Reader software? So do you know how Foxit PDF Reader converts pdf documents into jpg images? The following article brings you how Foxit PDF Reader converts pdf documents into jpg images. For those who are interested in the method of converting jpg images, please come and take a look below. First start Foxit PDF Reader, then find "Features" on the top toolbar, and then select the "PDF to Others" function. Next, open a web page called "Foxit PDF Online Conversion". Click the "Login" button on the upper right side of the page to log in, and then turn on the "PDF to Image" function. Then click the upload button and add the pdf file you want to convert into an image. After adding it, click "Start Conversion"

When using WPS office software, we found that not only one form is used, tables and pictures can be added to the text, pictures can also be added to the table, etc. These are all used together to make the content of the entire document look richer. , if you need to insert two pictures into the document and they need to be arranged side by side. Our next course can solve this problem: how to place two pictures side by side in a wps document. 1. First, you need to open the WPS software and find the picture you want to adjust. Left-click the picture and a menu bar will pop up, select "Page Layout". 2. Select "Tight wrapping" in text wrapping. 3. After all the pictures you need are confirmed to be set to "Tight text wrapping", you can drag the pictures to the appropriate position and click on the first picture.

WPS is a commonly used office software suite, and the WPS table function is widely used for data processing and calculations. In the WPS table, there is a very useful function, the DATEDIF function, which is used to calculate the time difference between two dates. The DATEDIF function is the abbreviation of the English word DateDifference. Its syntax is as follows: DATEDIF(start_date,end_date,unit) where start_date represents the starting date.
