SetNumberFormat — Set the separators used when formatting number labels


$plot->SetNumberFormat($decimal_point, $thousands_sep)


SetNumberFormat sets the separator characters used when formatting number labels. Labels are formatted as numbers when the 'data' format type is selected with SetXLabelType or SetYLabelType.



The character used as a decimal point, to separate the integer part of the label from the fraction part.


The character used as a thousands grouping separator (placed between every group of 3 digits left of the decimal point).


These separators are only used for labels when 'data' mode formatting is selected with SetXLabelType or SetYLabelType.

If SetNumberFormat is not used, PHPlot attempts to get the proper separator characters from your system locale. If this works and your locale is set correctly, you will probably not need to use this function. If locale information is not available, the default for decimal_point is a period, and the default for thousands_sep is a comma.

If your system locale is set to "C" or "POSIX", you might find that there are no thousands separators in your formatted labels. This is the correct behavior for those locales. If you cannot select a more specific locale, use SetNumberFormat to set the correct separators.

To set the number of decimal places, use SetPrecisionX and SetPrecisionY.

If you are trying to force a specific locale with setlocale(), it will not work, because PHPlot uses setlocale(LC_ALL, '') to import locale information from the system, and this overrides a forced locale from your script. On non-Windows platforms, you can force a locale using environment variables, but this does not work on Windows. To address this, PHPlot has (see the History section below) a special member variable locale_override that prevents PHPlot from importing locale settings from the system. For example, if the following code is used, numeric formatting will use the fr_CA locale settings, regardless of the system locale.

setlocale(LC_ALL, 'fr_CA');  # On Windows use: 'French_Canada'
$plot = new PHPlot(800, 600);
$plot->locale_override = True;


The locale_override hook was added in PHPlot-5.1.0. Before that, there was no way to force a specific locale on Windows, and on other platforms a locale could be forced only by using environment variables. The hook was added primarily for testing on Windows, but could be needed in other situations too.

This function was added to PHPlot-5.0.4. Versions up to and including 5.0rc3 always used a period for decimal point, and comma for thousands separator. Logo

This version of the manual was produced for the PHPlot Sourceforge project web service site, which requires the logo on each page.

To download a logo-free copy of the manual, see the PHPlot project downloads area.