[Chicago-talk] Producing a GD::Graph
Jay Strauss
me at heyjay.com
Sun Jan 15 07:50:00 PST 2006
Hi,
I'm trying to produce a graph for stock prices. I'd very much like it to look
like:
http://ipo-australia.com/scgi-bin/beta/graph.cgi?graph=XAO_year_550x350
I can't seem to conjure the correct parms for the graph. Below (or attached)
is my code and data. Does anyone have an idea of how you produce a graph,
where the x axis just shows the month intervals? And then produce tick lines
rise to meet the graph?
Thanks
Jay
#!/usr/bin/perl
use strict;
use warnings;
use Date::Calc qw(Delta_Days Add_Delta_Days);
use GD::Graph::lines;
my @data;
while (<DATA>) {
my ($date, $price) = split(/\s+/);
my @date = split(/\//, $date);
push @data, [\@date, $price];
}
my @begin = @{$data[0][0]};
my @clean;
foreach my $pt (@data) {
my $index = Delta_Days(@begin, @{$pt->[0]});
$clean[$index] = $pt;
}
my (@dates, @prices);
foreach my $index (0..$#clean) {
my @date = Add_Delta_Days(@begin, $index);
my $date;
# if ($date[1] == 1) {
$date = join("/", @date);
# }
push @dates, $date;
push @prices, $clean[$index][1];
}
my $graph = new GD::Graph::lines(600,600);
$graph->set(
x_label => 'Date',
y_label => 'Price',
# title => 'A Simple Line Graph',
# y_max_value => 50,
y_min_value => 900,
y_max_value => 1100,
# y_tick_number => 14,
y_label_skip => 0,
box_axis => 0,
line_width => 3,
# x_ticks=> 1,
long_ticks =>1,
transparent => 0,
y_tick_number => 4,
x_tick_number => 'auto',
#y_label_skip => 2,
#x_label_skip => 10,
);
$graph->plot([\@dates, \@prices]);
open(IMG, '>new_graph.png') or die $!;
binmode IMG;
print IMG $graph->gd->png();
__DATA__
2003/06/23 909.09
2003/11/14 962.92
2003/11/17 963.03
2003/11/18 964.35
2003/11/19 963.11
2003/11/20 961.88
2003/11/21 961.92
2003/11/24 962.03
2003/11/25 963.34
2003/11/26 963.37
2003/11/27 963.41
2003/11/28 963.45
2003/12/01 964.78
2003/12/02 965.25
2003/12/03 966.29
2003/12/04 966.75
2003/12/05 966.34
2003/12/08 965.87
2003/12/09 967.74
2003/12/10 963.03
2003/12/11 963.1
2003/12/12 964.23
2003/12/14 964.3
2003/12/15 965.01
2003/12/16 964.41
2003/12/17 966.49
2003/12/18 965.72
2003/12/19 965.11
2003/12/21 965.18
2003/12/22 967.11
2003/12/23 967.92
2003/12/24 967.25
2003/12/25 967.29
2003/12/26 969.5
2003/12/29 970.93
2003/12/30 971.41
2003/12/31 971.19
2004/01/01 971.19
2004/01/02 971.19
2004/01/05 971.48
2004/01/06 971.96
2004/01/07 965.72
2004/01/08 965.54
2004/01/09 967.06
2004/01/12 959.61
2004/01/13 963.36
2004/01/14 957.79
2004/01/15 956
2004/01/16 955.13
2004/01/18 955.13
2004/01/19 955.13
2004/01/20 957.09
2004/01/21 962.16
2004/01/22 963.42
2004/01/23 965.4
2004/01/24 965.4
2004/01/26 960.58
2004/01/27 968.93
2004/01/28 969.13
2004/01/29 966.07
2004/01/30 967.37
2004/01/31 967.29
2004/02/02 967.89
2004/02/03 968.31
2004/02/04 970.45
2004/02/05 969.32
2004/02/06 973.72
2004/02/08 973.81
2004/02/09 974.92
2004/02/10 974.42
2004/02/11 975.65
2004/02/12 976.83
2004/02/13 976.97
2004/02/16 976.97
2004/02/17 979.22
2004/02/18 979.4
2004/02/19 979.03
2004/02/20 977.28
2004/02/21 977.28
2004/02/22 977.28
2004/02/23 978.31
2004/02/24 979.28
2004/02/25 979
2004/02/26 979.54
2004/02/27 980.53
2004/02/29 980.61
2004/03/01 982.5
2004/03/02 982.42
2004/03/03 981.3
2004/03/04 981.91
2004/03/05 983.93
2004/03/08 982.69
2004/03/09 982.58
2004/03/10 977.31
2004/03/11 975.66
2004/03/12 979.1
2004/03/14 979.1
2004/03/15 974.86
2004/03/16 974.13
2004/03/17 978.56
2004/03/18 980.58
2004/03/19 978.9
2004/03/22 974.35
2004/03/23 974.96
2004/03/24 972.86
2004/03/25 978.94
2004/03/26 982.05
2004/03/28 981.39
2004/03/29 983.34
2004/03/30 984.78
2004/03/31 984.73
2004/04/01 985.1
2004/04/02 986.92
2004/04/03 985.45
2004/04/05 985.26
2004/04/06 984.38
2004/04/07 985.5
2004/04/08 985.69
2004/04/09 986.33
2004/04/12 986.33
2004/04/13 982.58
2004/04/14 983.45
2004/04/15 983.42
2004/04/16 983.45
2004/04/19 984.94
2004/04/20 981.8
2004/04/21 980.88
2004/04/22 976.34
2004/04/23 979.97
2004/04/26 978.77
2004/04/27 979.88
2004/04/28 977.29
2004/04/29 977.23
2004/04/30 974.43
2004/05/03 978.15
2004/05/04 980.94
2004/05/05 981.34
2004/05/06 978.17
2004/05/07 977.89
2004/05/10 974.89
2004/05/11 974.9
2004/05/12 974.79
2004/05/13 974.19
2004/05/14 975.58
2004/05/17 973.29
2004/05/18 973.14
2004/05/19 978.24
2004/05/20 977.18
2004/05/21 979.02
2004/05/24 980.32
2004/05/25 983.33
2004/05/26 985.58
2004/05/27 986.53
2004/05/28 982.62
2004/05/31 982.62
2004/06/01 983.91
2004/06/02 983.24
2004/06/03 984.36
2004/06/04 983.95
2004/06/07 980.94
2004/06/08 980.26
2004/06/09 985.03
2004/06/10 986.15
2004/06/11 986.58
2004/06/14 986.53
2004/06/15 988.8
2004/06/16 989.54
2004/06/17 991.14
2004/06/18 992.64
2004/06/21 995.52
2004/06/22 996.53
2004/06/23 995.65
2004/06/24 996.81
2004/06/25 997.09
2004/06/28 997.76
2004/06/29 995.82
2004/06/30 996.8
2004/07/01 997.1
2004/07/02 997.88
2004/07/05 998.07
2004/07/06 994.84
2004/07/07 997.11
2004/07/08 996.09
2004/07/09 996.01
2004/07/12 992.72
2004/07/13 995.94
2004/07/14 993.53
2004/07/15 993.87
2004/07/16 993.45
2004/07/19 992.68
2004/07/20 996.88
2004/07/21 993.9
2004/07/22 993.06
2004/07/23 988.82
2004/07/26 986.22
2004/07/27 989.38
2004/07/28 990.94
2004/07/29 995.28
2004/07/30 995.01
2004/08/02 997.52
2004/08/03 996.9
2004/08/04 995.67
2004/08/05 989.61
2004/08/06 984.19
2004/08/09 982.31
2004/08/10 989.69
2004/08/11 986.7
2004/08/12 986.7
2004/08/13 983.36
2004/08/16 991.3
2004/08/17 993.08
2004/08/18 999.44
2004/08/19 999.9
2004/08/20 1001.25
2004/08/23 1004.29
2004/08/24 1004
2004/08/25 1005.75
2004/08/26 1006.34
2004/08/27 1005.6
2004/08/30 1006.24
2004/08/31 1006.27
2004/09/02 1007.51
2004/09/07 1007.79
2004/09/08 1008.18
2004/09/09 1008.64
2004/09/10 1009.43
2004/09/13 1012.8
2004/09/14 1012.23
2004/09/15 1010.62
2004/09/17 1011.87
2004/09/20 1012.51
2004/09/21 1013.55
2004/09/22 1014.9
2004/09/23 1015.1
2004/09/24 1014.74
2004/09/27 1013.65
2004/09/28 1016.52
2004/09/29 1016.76
2004/09/30 1016.81
2004/10/01 1019.01
2004/10/04 1019.61
2004/10/05 1020.24
2004/10/06 1020.36
2004/10/11 1019.51
2004/10/12 1018.26
2004/10/13 1016.7
2004/10/14 1017.72
2004/10/15 1018.21
2004/10/18 1016.38
2004/10/19 1016.97
2004/10/20 1017.15
2004/10/21 1017.08
2004/10/22 1017.14
2004/10/25 1017.7
2004/10/26 1017.9
2004/10/27 1017.4
2004/10/28 1016.05
2004/10/29 1014.84
2004/11/01 1014.54
2004/11/02 1013.39
2004/11/03 1013.02
2004/11/04 1015.04
2004/11/05 1014.87
2004/11/08 1013.19
2004/11/09 1015.55
2004/11/10 1015.48
2004/11/11 1013.69
2004/11/12 1014.86
2004/11/15 1008.46
2004/11/16 1010.87
2004/11/17 1001.76
2004/11/18 997.05
2004/11/19 1010.79
2004/11/22 1016.5
2004/11/23 1010.38
2004/11/24 1011.53
2004/11/29 1012.7
2004/11/30 1012.66
2004/12/01 1007.42
2004/12/02 1001.02
2004/12/03 1001.63
2004/12/06 1000.2
2004/12/07 1003.14
2004/12/08 1004.46
2004/12/09 1000.48
2004/12/10 1004.11
2004/12/13 998.93
2004/12/14 997.79
2004/12/15 997.27
2004/12/16 1002.68
2004/12/17 1005.855
2004/12/20 1009.71
2004/12/21 1008.46
2004/12/22 1007.68
2004/12/23 1006.35
2004/12/24 1006.35
2004/12/27 1006.63
2004/12/28 1006.91
2004/12/29 1005.05
2004/12/30 1005.7
2005/01/01 1005.5
2005/01/04 1012.68
2005/01/06 1014.66
2005/01/07 1014.05
2005/01/10 1016.01
2005/01/11 1017.51
2005/01/12 1017.14
2005/01/13 1016.62
2005/01/14 1018.66
2005/01/18 1018.97
2005/01/19 1018.43
2005/01/20 1019.8
2005/01/21 1021.82
2005/01/24 1022.5
2005/01/25 1022.47
2005/01/26 1022.75
2005/01/27 1022.79
2005/01/28 1022.8
2005/01/31 1022.85
2005/02/01 1023.16
2005/02/02 1022.87
2005/02/03 1020.8
2005/02/04 1020.92
2005/02/07 1020.9
2005/02/09 1020.91
2005/02/10 1020.98
2005/02/11 1021.05
2005/02/16 1024.26
2005/02/17 1024.38
2005/02/18 1024.42
2005/02/21 1024.55
2005/02/22 1024.9
2005/02/23 1024.78
2005/02/24 1024.42
2005/02/25 1024.46
2005/02/28 1025.12
2005/03/01 1024.6
2005/03/02 1025.03
2005/03/03 1025
2005/03/04 1025.37
2005/03/07 1024.93
2005/03/08 1025.68
2005/03/09 1025.53
2005/03/10 1024.96
2005/03/11 1025.03
2005/03/14 1024.94
2005/03/15 1025.01
2005/03/16 1025.15
2005/03/18 1026.31
2005/03/21 1026.45
2005/03/22 1026.7
2005/03/23 1026.47
2005/03/24 1026.47
2005/03/28 1026.54
2005/03/29 1026.49
2005/03/30 1027.21
2005/03/31 1027.99
2005/04/01 1027.89
2005/04/04 1027.83
2005/04/05 1028.71
2005/04/06 1028.87
2005/04/07 1028.84
2005/04/08 1029.28
2005/04/11 1029.03
2005/04/12 1029.48
2005/04/13 1028.62
2005/04/14 1027.76
2005/04/15 1025.33
2005/04/18 1019.56
2005/04/19 1022.55
2005/04/20 1021.03
2005/04/21 1022.9
2005/04/22 1022.99
2005/04/25 1022.93
2005/04/26 1023.81
2005/04/27 1022.29
2005/04/28 1020.15
2005/04/29 1020.42
2005/05/02 1022.5
2005/05/03 1022.22
2005/05/04 1027.76
2005/05/05 1028.29
2005/05/06 1029.33
2005/05/09 1031.1
2005/05/10 1031.39
2005/05/11 1030.41
2005/05/12 1028.97
2005/05/13 1029.01
2005/05/16 1029.01
2005/05/17 1030.04
2005/05/18 1030.45
2005/05/19 1031.61
2005/05/20 1030.9
2005/05/23 1032.84
2005/05/24 1033.59
2005/05/25 1035.43
2005/05/26 1036.01
2005/05/27 1037.2
2005/05/31 1036.55
2005/06/02 1036.83
2005/06/03 1036.58
2005/06/06 1037.83
2005/06/07 1037.67
2005/06/08 1037.7
2005/06/09 1037.78
2005/06/10 1038.07
2005/06/13 1038.27
2005/06/14 1037.91
2005/06/15 1039.08
2005/06/16 1039.07
2005/06/17 1039.08
2005/06/20 1041.49
2005/06/21 1042.75
2005/06/22 1042.43
2005/06/23 1042.91
2005/06/24 1043.01
2005/06/27 1043.03
2005/06/28 1042.82
2005/06/29 1043.46
2005/06/30 1043.45
2005/07/01 1043.49
2005/07/05 1042.31
2005/07/06 1043.04
2005/07/07 1043.44
2005/07/08 1043.73
2005/07/11 1049.47
2005/07/12 1049.87
2005/07/13 1049.91
2005/07/14 1047.91
2005/07/15 1046.4
2005/07/18 1047.95
2005/07/19 1045.84
2005/07/20 1045.9
2005/07/21 1046.63
2005/07/22 1046.63
2005/07/25 1047.33
2005/07/26 1045.85
2005/07/28 1047.17
2005/08/01 1045.53
2005/08/02 1045.73
2005/08/03 1045.32
2005/08/04 1045.25
2005/08/05 1046.3
2005/08/08 1046.28
2005/08/09 1048.39
2005/08/10 1052.32
2005/08/11 1053.27
2005/08/12 1053.14
2005/08/15 1054.51
2005/08/16 1054.04
2005/08/17 1055.83
2005/08/18 1058.96
2005/08/19 1059.6
2005/08/22 1062.11
2005/08/23 1060.09
2005/08/24 1061.5
2005/08/25 1063.06
2005/08/26 1061.7
2005/08/30 1059.67
2005/08/31 1062.16
2005/09/01 1062.7
2005/09/02 1064.5
2005/09/05 1064.63
2005/09/06 1063.43
2005/09/07 1062.77
2005/09/08 1063.23
2005/09/09 1061.53
2005/09/12 1061.08
2005/09/13 1062.3
2005/09/14 1063.49
2005/09/15 1062.04
2005/09/16 1066.73
2005/09/19 1067.67
2005/09/20 1066.98
2005/09/21 1068.43
2005/09/22 1068.36
2005/09/23 1065.22
2005/09/26 1068.9
2005/09/27 1067.91
2005/09/28 1068.14
2005/09/29 1069.78
2005/09/30 1067.07
2005/10/03 1070.11
2005/10/05 1069.17
2005/10/06 1070.62
2005/10/07 1070.36
2005/10/10 1071.7
2005/10/11 1072.47
2005/10/12 1074.11
2005/10/14 1071.89
2005/10/17 1076.02
2005/10/18 1073.79
2005/10/19 1075.63
2005/10/20 1072.38
2005/10/21 1072.23
2005/10/24 1075.54
2005/10/27 1075.55
2005/10/28 1075.6
2005/10/31 1075.61
2005/11/01 1077.11
2005/11/02 1077.72
2005/11/03 1076.72
2005/11/04 1075.08
2005/11/07 1075.01
2005/11/08 1073.97
2005/11/09 1074.33
2005/11/10 1071.35
2005/11/11 1070.55
2005/11/14 1069.91
2005/11/15 1072.59
2005/11/16 1071.49
2005/11/17 1068.11
2005/11/18 1066.5
2005/11/21 1063.7
2005/11/22 1062.47
2005/11/23 1061.21
2005/11/25 1060.69
2005/11/28 1067.28
2005/11/29 1067.68
2005/11/30 1069.74
2005/12/01 1062.17
2005/12/02 1060.97
2005/12/05 1065.7
2005/12/06 1066.42
2005/12/07 1066.96
2005/12/08 1069.25
2005/12/09 1069.27
2005/12/12 1066.42
2005/12/13 1067.4
2005/12/14 1069.85
2005/12/15 1069.96
2005/12/16 1073.82
2005/12/19 1077.61
2005/12/20 1077.3
2005/12/21 1077.43
2005/12/22 1078.45
2005/12/23 1079.08
2005/12/27 1079.91
2005/12/28 1080.68
2005/12/29 1080.04
2005/12/30 1081.15
2005/12/31 1083.45
2006/01/01 1083.45
2006/01/04 1082.25
2006/01/05 1081.59
2006/01/06 1073.29
2006/01/09 1072.11
2006/01/10 1067.56
2006/01/11 1065.03
2006/01/12 1067.54
2006/01/13 1069.43
More information about the Chicago-talk
mailing list