1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_scatter.php'); |
---|
4 | require_once ('jpgraph/jpgraph_line.php'); |
---|
5 | require_once ('jpgraph/jpgraph_plotline.php'); |
---|
6 | |
---|
7 | $numpoints=50; |
---|
8 | $k=0.05; |
---|
9 | |
---|
10 | // Create some data points |
---|
11 | for($i=-$numpoints+1; $i<0; ++$i) { |
---|
12 | $datay[$i+$numpoints-1]=exp($k*$i)*cos(2*M_PI/10*$i)*14; |
---|
13 | $datayenv[$i+$numpoints-1]=exp($k*$i)*14; |
---|
14 | $datax[$i+$numpoints-1]=$i; |
---|
15 | } |
---|
16 | |
---|
17 | for($i=0; $i<$numpoints; ++$i) { |
---|
18 | $datay[$i+$numpoints-1]=exp(-$k*$i)*cos(2*M_PI/10*$i)*14; |
---|
19 | $datayenv[$i+$numpoints-1]=exp(-$k*$i)*14; |
---|
20 | $datax[$i+$numpoints-1]=$i; |
---|
21 | } |
---|
22 | |
---|
23 | // Setup the basic parameters for the graph |
---|
24 | $graph = new Graph(500,250); |
---|
25 | $graph->SetScale("intlin"); |
---|
26 | |
---|
27 | $graph->SetShadow(); |
---|
28 | $graph->SetBox(); |
---|
29 | $graph->title->Set("Impuls Example 4"); |
---|
30 | $graph->title->SetFont(FF_FONT1,FS_BOLD); |
---|
31 | |
---|
32 | // Set some other color then the boring default |
---|
33 | $graph->SetColor("lightyellow"); |
---|
34 | $graph->SetMarginColor("khaki"); |
---|
35 | |
---|
36 | // Set legend box specification |
---|
37 | $graph->legend->SetFillColor("white"); |
---|
38 | $graph->legend->SetLineWeight(2); |
---|
39 | |
---|
40 | // Set X-axis at the minimum value of Y-axis (default will be at 0) |
---|
41 | $graph->xaxis->SetPos("min"); // "min" will position the x-axis at the minimum value of the Y-axis |
---|
42 | |
---|
43 | // Extend the margin for the labels on the Y-axis and reverse the direction |
---|
44 | // of the ticks on the Y-axis |
---|
45 | $graph->yaxis->SetLabelMargin(12); |
---|
46 | $graph->xaxis->SetLabelMargin(6); |
---|
47 | $graph->yaxis->SetTickSide(SIDE_LEFT); |
---|
48 | $graph->xaxis->SetTickSide(SIDE_DOWN); |
---|
49 | |
---|
50 | // Add mark graph with static lines |
---|
51 | $line = new PlotLine(HORIZONTAL,0,"black",2); |
---|
52 | $graph->AddLine($line); |
---|
53 | |
---|
54 | // Create a new impuls type scatter plot |
---|
55 | $sp1 = new ScatterPlot($datay,$datax); |
---|
56 | $sp1->mark->SetType(MARK_SQUARE); |
---|
57 | $sp1->mark->SetFillColor("red"); |
---|
58 | $sp1->mark->SetWidth(3); |
---|
59 | |
---|
60 | $sp1->SetImpuls(); |
---|
61 | $sp1->SetColor("blue"); |
---|
62 | $sp1->SetWeight(1); |
---|
63 | $sp1->SetLegend("Non-causal signal"); |
---|
64 | |
---|
65 | $graph->Add($sp1); |
---|
66 | |
---|
67 | // Create the envelope plot |
---|
68 | $ep1 = new LinePlot($datayenv,$datax); |
---|
69 | $ep1->SetStyle("dotted"); |
---|
70 | $ep1->SetLegend("Positive envelope"); |
---|
71 | |
---|
72 | $graph->Add($ep1); |
---|
73 | |
---|
74 | $graph->Stroke(); |
---|
75 | |
---|
76 | ?> |
---|