Is it possible to set XDataLabelPos to 'plotin' in a 'points' graph? I tried using SetYDataLabelPos to 'plotin', but this just labeled the points with their Y values. I want the points labeled with the text name associated with the point in the array.
~~~~~~~~~~~~
// Make a points plot using the above data:
$plot = new PHPlot($height, $width);
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetPlotType('points');
$plot->SetTitle('Map');
$plot->SetPlotAreaWorld(-1 * $worldrow["size"], -1 * $worldrow["size"], $worldrow["size"], #$worldrow["size"]);
// Move axes and ticks to 0,0, but turn off tick labels:
$plot->SetXAxisPosition(0); # Is default
$plot->SetYAxisPosition(0);
$plot->SetXTickPos('xaxis');
$plot->SetXTickLabelPos('none');
$plot->SetYTickPos('yaxis');
$plot->SetYTickLabelPos('none');
$plot->SetXDataLabelPos('plotin');
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Last edit: Timothy Edgar 2014-03-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes it is possible, but it takes a bit of work. Firstly, though, what you want are Y data labels, not X data labels. I know this sounds wrong, but by default these labels display the Y values at the data points, so they are called Y data labels.
Secondly, you will use a custom label formatting function to make the label text equal to the values from your data array. PHPlot-5.8.0 or higher is required in order to use the $row argument with custom label formatting.
<?phprequire_once"phplot.php";// Y Data Labels above the points, showing the labels from the data array.$data=array(array('Jan',1,0),array('Feb',2,10),array('Mar',3,20),array('Apr',4,25),array('May',5,18),array('Jun',6,12),);functionget_label($ignored_label,$data,$row=NULL,$ignored_column=NULL){return$data[$row][0];}$plot=newPHPlot(600,400);$plot->SetDataType('data-data');$plot->SetDataValues($data);$plot->SetPlotType('points');$plot->SetYDataLabelType('custom','get_label',$data);$plot->SetYDataLabelPos('plotin');$plot->SetXTickLabelPos('none');$plot->SetXDataLabelPos('none');$plot->DrawGraph();
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible to set XDataLabelPos to 'plotin' in a 'points' graph? I tried using SetYDataLabelPos to 'plotin', but this just labeled the points with their Y values. I want the points labeled with the text name associated with the point in the array.
~~~~~~~~~~~~
// Make a points plot using the above data:
$plot = new PHPlot($height, $width);
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetPlotType('points');
$plot->SetTitle('Map');
$plot->SetPlotAreaWorld(-1 * $worldrow["size"], -1 * $worldrow["size"], $worldrow["size"], #$worldrow["size"]);
// Move axes and ticks to 0,0, but turn off tick labels:
$plot->SetXAxisPosition(0); # Is default
$plot->SetYAxisPosition(0);
$plot->SetXTickPos('xaxis');
$plot->SetXTickLabelPos('none');
$plot->SetYTickPos('yaxis');
$plot->SetYTickLabelPos('none');
$plot->SetXDataLabelPos('plotin');
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Last edit: Timothy Edgar 2014-03-21
Yes it is possible, but it takes a bit of work. Firstly, though, what you want are Y data labels, not X data labels. I know this sounds wrong, but by default these labels display the Y values at the data points, so they are called Y data labels.
Secondly, you will use a custom label formatting function to make the label text equal to the values from your data array. PHPlot-5.8.0 or higher is required in order to use the $row argument with custom label formatting.
More information is in the manual here and also see the reference for SetXDataLabelType
Here is a simple, complete example:
Awesome. Thank you! Works perfectly.