|
skew t log p |
Posted by wolkenloseswetter on Apr-18-2011 02:02 |
|
Hi!
I will create a so named "skew t lop p" diagramm for displaying radiosonde-data. The y
axis should be the pressure (increasing values!) and the x-axis the temperature or
dewpoint. Now i want a logaritmic y-scale like it's shown in the example.
"Axis.setLogScale" will not work. Can you help me? Here is my code:
##########################################
<?php
require_once("phpchartdir.php");
$druck_array=array
(1012,1004,1000,943,925,917,853,850,814,798,767,762,700,608,583,579,575,564,549,50
2,500,488,479,466,464,436,423,405,400,398,378,367,334,318,314,300,259,250,237,203,
200,188,180,164,150,130,129,124,107,101,100);
$temperatur_array=array (31,28.4,27.8,23,23,23.2,20.8,20.6,17.8,16.2,14.5,14.2,7.8,-
2.9,-5.3,-4.7,-5.1,-6.1,-7.1,-11.5,-11.7,-13.5,-13.5,-14.3,-14.6,-18.3,-20.3,-23.3,-
24.3,-24.5,-26.9,-28.3,-34.3,-36.3,-37,-39.7,-48.7,-50.3,-53.5,-59.2,-59.7,-60.5,-60,-
59.1,-58.1,-57.7,-57.2,-54.7,-55.9,-56.3,-56.1);
$taupunkt_array=array (23,20.4,20.8,19.8,17,15.2,4.8,4.6,1.8,5.2,-0.8,-1.8,-2.2,-5.7,-
12.3,-19.7,-18.2,-14.1,-27.1,-33.5,-29.7,-28.5,-43.5,-54.3,-54.8,-62.3,-36.3,-37.3,-
39.3,-39.5,-49.9,-46.3,-44.3,-52.3,-52.4,-52.7,-59.7,-60.3,-62.5,-70,-70.7,-73.5,-75,-
78.1,-80.1,-89.7,-89.2,-86.7,-87.8,-88.3,-88.1);
$data0 = $temperatur_array;
$data1 = $taupunkt_array;
$labels = $druck_array;
$c = new XYChart(640, 610, 0xeeeeff, 0x000000, 1);
$c->enableVectorOutput();
$c->setRoundedFrame();
$c->setPlotArea(50, 50, 550, 500, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
$legendObj = $c->addLegend(50, 30, false, "arialbd.ttf", 9);
$legendObj->setBackground(Transparent);
$textBoxObj = $c->addTitle("Skew T log p", "timesb.ttf", 14);
$textBoxObj->setBackground(0xccccff, 0x000000, glassEffect());
$layer1 = $c->addLineLayer2();
$layer1->setLineWidth(1);
$layer1->addDataSet($data0, 0x008800, "Temperature");
$layer2 = $c->addLineLayer2();
$layer2->setLineWidth(1);
$layer2->addDataSet($data1, 0xff00000, "Dewpoint");
$c->yAxis->setTitle("Grad Celsius");
$c->yAxis->setLabelStep(20);
$c->xAxis->setLabels($labels);
$c->xAxis->setTitle("Pressure");
$c->swapXY();
# Output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>
##########################################
First Image is my current image without logaritmic pressure scale.
Second Image is an example for a logaritmic pressure scale.
Thanks!
|
Re: skew t log p |
Posted by Peter Kwan on Apr-19-2011 00:39 |
|
Hi wolkenlosewetter,
For your case, the $druck_array should be treated as the x-coordinates of the data points, instead of the x-axis labels. You can then use Axis.setLogScale to configure a log scale axis. The code is something like:
<?php
require_once("phpchartdir.php");
$druck_array=array(1012,1004,1000,943,925,917,853,850,814,798,767,762,700,608,583,579,575,564,549,502,500,488,479,466,464,436,423,405,400,398,378,367,334,318,314,300,259,250,237,203,200,188,180,164,150,130,129,124,107,101,100);
$temperatur_array=array(31,28.4,27.8,23,23,23.2,20.8,20.6,17.8,16.2,14.5,14.2,7.8,-2.9,-5.3,-4.7,-5.1,-6.1,-7.1,-11.5,-11.7,-13.5,-13.5,-14.3,-14.6,-18.3,-20.3,-23.3,-24.3,-24.5,-26.9,-28.3,-34.3,-36.3,-37,-39.7,-48.7,-50.3,-53.5,-59.2,-59.7,-60.5,-60,-59.1,-58.1,-57.7,-57.2,-54.7,-55.9,-56.3,-56.1);
$taupunkt_array=array(23,20.4,20.8,19.8,17,15.2,4.8,4.6,1.8,5.2,-0.8,-1.8,-2.2,-5.7,-12.3,-19.7,-18.2,-14.1,-27.1,-33.5,-29.7,-28.5,-43.5,-54.3,-54.8,-62.3,-36.3,-37.3,-39.3,-39.5,-49.9,-46.3,-44.3,-52.3,-52.4,-52.7,-59.7,-60.3,-62.5,-70,-70.7,-73.5,-75,-78.1,-80.1,-89.7,-89.2,-86.7,-87.8,-88.3,-88.1);
$data0 = $temperatur_array;
$data1 = $taupunkt_array;
$labels = $druck_array;
$c = new XYChart(640, 610, 0xeeeeff, 0x000000, 1);
$c->enableVectorOutput();
$c->setRoundedFrame();
$c->setPlotArea(50, 60, 550, 500, 0xffffff, -1, -1, 0xcccccc, 0xcccccc);
$legendObj = $c->addLegend(50, 30, false, "arialbd.ttf", 9);
$legendObj->setBackground(Transparent);
$textBoxObj = $c->addTitle("Skew T log p", "timesb.ttf", 14);
$textBoxObj->setBackground(0xccccff, 0x000000, glassEffect());
$layer1 = $c->addLineLayer2();
$layer1->setLineWidth(1);
$layer1->addDataSet($data0, 0x008800, "Temperature");
$layer1->addDataSet($data1, 0xff0000, "Dewpoint");
$layer1->setXData($labels);
$c->yAxis->setTitle("Grad Celsius");
$c->yAxis->setLabelStep(20);
$c->xAxis->setLogScale();
$c->xAxis->setReverse();
$c->xAxis->setTitle("Pressure");
$c->swapXY();
# Output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>
Hope this can help.
Regards
Peter Kwan
|
Re: skew t log p |
Posted by wolkenloseswetter on May-06-2011 17:26 |
|
Thanks Peter! This looks like it should be!!!!
wolkenlosewetter |
|