Graphing libraries to create grid like charts

Posted on 2008-06-23
Last Modified: 2012-05-05
I want to create some graphs programatically, using Java or Perl. I want to replicate a graph like the following on 'grid paper':

|    U

The only thing missing from the example is the grid background (sorry, i am not that talented to show that here). For Java, i found the library jfreecharts, but I didnt dig too deep into it. For perl, i found GD::Charts. Nice module, but I couldnt figure out how to create the grids properly...

I am looking for code examples, not pointers to doc (of course I would like pointers if you also give me code samples).
Question by:kawas
  • 3
  • 3
LVL 39

Expert Comment

Comment Utility
I've looked at both jfreecharts and GD::Charts, and either I don't understand your ascii chart, or I don't think they'll give you want you want.

Would it be possible for you to provide a graphical version of what you want.  EE now allows you to attach images.  This would make it easier.
LVL 13

Author Comment

Comment Utility
maybe something along the lines of:

They have a similar type chart near the bottom
LVL 39

Expert Comment

Comment Utility
I don't think either the GD::Charts or eh jfreecharts will do that.  If you saw they could, I might have missed something.

If your output is going to a webpage, you might just want to use an HTML table - which is what the site is using.

Otherwise, I don't know of a module that creates tables like those.  I think you could just use the GD module to draw them though.
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

LVL 13

Author Comment

Comment Utility
how hard would it be to use GD directly? Do you have experience? Perhaps a small example to get me going? Thanks Adam
LVL 24

Expert Comment

Comment Utility
May be this can be done by the development library that comes with OpenOffice.
I have no experience with it.
Please look at:

Check out "R4Calc".

LVL 39

Accepted Solution

Adam314 earned 500 total points
Comment Utility


use strict;

use warnings;

use Data::Dumper;

use GD;

my @data = 


   [19, 'x'],

   [18, undef, 'x'],

   [17, undef, undef, 'a'],


my $Rows = 4;

my $Cols = 4;   

my $Width=200;

my $Height=100;

my $image = new GD::Image($Width,$Height);

my $white = $image->colorAllocate(255,255,255);

my $black = $image->colorAllocate(0,0,0);

my $grey  = $image->colorAllocate(192,192,192);

#First, draw grid

for(my $row=0; $row<=$Rows; $row++) {

	my $y=($row/$Rows)*($Height-1);



for(my $col=0; $col<=$Cols; $col++) {

	my $x=($col/$Cols)*($Width-1);



for(my $row=0; $row<$Rows; $row++) {

	for(my $col=0; $col<$Cols; $col++) {

		my $y=($row/$Rows)*$Height+5;  # +5 for border

		my $x=($col/$Cols)*$Width+5;   # +5 for border

		my $string = ($data[$row]->[$col] or "");




open(my $OUT, ">out1.png") or die "output: $!\n";


print $OUT $image->png;


Open in new window

LVL 13

Author Closing Comment

Comment Utility

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now