Forum archive 2000-2006

Lars Jensen - Formatting grid and tick mark labels

Lars Jensen - Formatting grid and tick mark labels

by Arnold Pizer -
Number of replies: 0
inactiveTopicFormatting grid and tick mark labels topic started 7/26/2004; 5:54:37 PM
last post 7/26/2004; 6:10:32 PM
userLars Jensen - Formatting grid and tick mark labels  blueArrow
7/26/2004; 5:54:37 PM (reads: 661, responses: 1)
When greating a problem with graphs, using init_graph, like below, I get tick mark labels with 16 decimal places. How do I format these labels so I only get one or two decimals on the label?

$graph_object = init_graph($xmin,$ymin,$xmax,$ymax, 'axes' => [0,0], 'ticks' => [10,8], 'pixels' => [300,300] );

Thanks, Lars.

<| Post or View Comments |>


userMichael Gage - Re: Formatting grid and tick mark labels  blueArrow
7/26/2004; 6:10:32 PM (reads: 835, responses: 0)
The simple technique is to make the number of ticks divide into the width and height (xmax-xmin) of the problem.

This could also be fixed by editing PGgraphmacros.pl so that the

the second $x_delta and $y_delta are formatted using sprintf.

lines 157

 



$graphRef->h_ticks(0,'black',@x_values);
$graphRef->v_ticks(0,'black',@y_values);
$graphRef->lb(new Label($x_delta,0,$x_delta,'black','right'));
$graphRef->lb(new Label(0,$y_delta,$y_delta,'black','top'));

and line 137 (grid)

		$graphRef->v_grid('gray',@x_values);
$graphRef->h_grid('gray',@y_values);
$graphRef->lb(new Label($x_delta,0,sprintf("%1.1f",$x_delta),'black','center','middle'));
$graphRef->lb(new Label(0,$y_delta,sprintf("%1.1f",$y_delta),'black','center','middle'));

I'll add this to the bug list.

<| Post or View Comments |>