New User Query : Plotting Vectors and Stacking Charts

A free public discussion forum for the JFreeChart class library.

New User Query : Plotting Vectors and Stacking Charts

Postby kerry » Fri Dec 01, 2006 9:26 pm

Hello,

I'm a new user and have a couple of questions for anyone that may care to answer them which will determine whether Jfreechart will suit my needs and I will purchase the developer's guide :

1) Is it possible to plot a vector field directly using JFreeChart (similar to the 'quiver'function in Matlab if anyone is familair with it ) or will I have to combine several components of JFreeChart to do this. I have an array of vectors, their directions are all the same but the lengths are all diffent, as is their co-ordinates, but I would like to plot them using JFreeChart if possible.

2) Is it possible to overlay several differing types of charts e.g. a line chart over laying a bar graph, in effect having two different charts on one graph.

Many thanks to anyone that reads or replies too.

Kerry
kerry
 
Posts: 2
Joined: Fri Dec 01, 2006 8:59 pm

Postby angel » Mon Dec 04, 2006 8:36 am

1)
Link to Matlab: http://www.mathworks.com/access/helpdes ... uiver.html

In JFreeChart there is a XY-WindChart (look at the demos) which works simmiliar to a vector chart. This is possible something for you.

2) Yes.
angel
 
Posts: 899
Joined: Thu Jan 15, 2004 12:07 am
Location: Germany - Palatinate

Postby regist » Sun Jan 28, 2007 10:21 pm

I guess XY-WindChart isn't suitable because, AFAIK, you cannot select the vertical axis starting point, and it's limited to 12 directions.

What I've done till now, to implement MatLab's "quiver" function for vectors "ex" and "ey" is:

Code: Select all
XYSeriesCollection dataset = new XYSeriesCollection();
       
        for(int i = 0; i < ex.length; i++)
         for(int j = 0; j < ex[0].length; j++)
         {
            XYSeries series = new XYSeries("N");
            series.add(j+1, i+1);
            series.add(j+1+ex[i][j], i+1+ey[i][j]);
            dataset.addSeries(series);
         }
        JFreeChart chart = ChartFactory.createXYLineChart(
                title,      // chart title
                "X",                      // x axis label
                "Y",                      // y axis label
                dataset,                  // data
                PlotOrientation.VERTICAL,
                false,                     // include legend
                true,                     // tooltips
                false                     // urls
            );
        ChartPanel chartPanel = new ChartPanel(chart);
        return chartPanel;


This code's got two problems:

1) It doesn't show an arrow at the ending point.

2) The colour of each line is different.

The second one is probably a newbie mistake (I'm pretty new to JFreeChart), and I haven't found a way to solve the first one (yet).

Hope it helps.
regist
 
Posts: 1
Joined: Sun Jan 28, 2007 10:14 pm

Postby david.gilbert » Tue Jan 30, 2007 5:49 pm

I've committed a new experimental VectorRenderer to CVS to generate this type of chart, along with a VectorXYDataset interface and a bunch of classes to provide an implementation of this dataset. They'll be included in the 1.0.4 release, in the 'experimental' source tree.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11319
Joined: Fri Mar 14, 2003 10:29 am


Return to JFreeChart - General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 17 guests

cron