Scatter Plot java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

25 views
Skip to first unread message

Srirama Bhamidipati

unread,
May 8, 2014, 11:24:50 AM5/8/14
to
Hi,

I am trying to draw a scatterplot between two lists. As I am doing scatter plots for the first time, for now, I have kept the both lists the same variable so that I can see a more or less 45 degree straight line. But, I get an error :-  java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

Here is the code

chart "DataScatter" type:scatter
{
data "people" value:(list(road) collect each.ADT) color: °red line_visible:false;
data "goods" value:(list(road) collect each.ADT)  color: °green line_visible:false;
}

Road is a species and has a float variable ADT. ADT is calculated in a global reflex. I do not understand why is it out of bounds.

please guide, thanks
Srirama

Philippe Caillou

unread,
May 8, 2014, 11:56:31 AM5/8/14
to gama-p...@googlegroups.com
Hi,

For a scatter plot, each value should be a point (or a list with two floats).
so something like that should work: (i just tested a similar thing with ants models) 
chart "DataScatter" type:scatter
{
data "goods" value:(list(road) collect {each.ADT,each.ADT})  color: °green line_visible:false;
}

Philippe


2014-05-08 17:21 GMT+02:00 Srirama Bhamidipati <b.sr...@gmail.com>:
Hi,

I am trying to draw a scatterplot between two lists. As I am doing scatter plots for the first time, for now, I have kept the both lists the same variable so that I can see a more of less 45 degree straight line. But, I get an error :-  java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

Here is the code

chart "DataScatter" type:scatter
{
data "people" value:(list(road) collect each.ADT) color: °red line_visible:false;
data "goods" value:(list(road) collect each.ADT)  color: °green line_visible:false;
}

Road is a species and has a float variable ADT. ADT is calculated in a global reflex. I do not understand why is it out of bounds.

please guide, thanks
Srirama

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.

Alexis Drogoul

unread,
May 8, 2014, 12:15:08 PM5/8/14
to gama-p...@googlegroups.com
Hi,

Maybe we could add a test on the type of the value passed to the facet value: (either in a validator, where you test both the type of plot and the type of the expression, or at runtime) ? In that way, we could avoid having this difficult-to-interpret error.

Cheers
Alexis
--
Senior Researcher, UMI UMMISCO 209, IRD & UPMC, France.
Invited Researcher, DREAM, Can Tho University, Viet Nam.
--
alexis....@gmail.com | http://tiny.cc/liqemw
[Vietnam] +84915088155 [France] +33608698845
--
GAMA: https://code.google.com/p/gama-platform/

Philippe Caillou

unread,
May 8, 2014, 1:01:49 PM5/8/14
to gama-p...@googlegroups.com
Hi,

Good idea, I just added a GamaRuntimeException (just discovered those, very useful!).

It would (perhaps?) be difficult to throw a warning in the editor since the value type constraints depends on the chart type (and it is possible to have points and list of points).

Philippe

Alexis Drogoul

unread,
May 8, 2014, 1:06:23 PM5/8/14
to gama-p...@googlegroups.com
Well, you should have a look at the IValidator interface and how it can be used (and how it is actually used) in such cases (basically, your data statement description can gather the enclosing description — chart —, verify its type — getFacets().get(…) — and verify the type of the value of its own facet value:

If you tell me exactly the rules to enforce, I can give you a draft of this validator.

Cheers
Alexis

Philippe Caillou

unread,
May 8, 2014, 1:15:09 PM5/8/14
to gama-p...@googlegroups.com
I never used IValidator either... A good way to learn!
Basically, the rule should be:

For the Data statement (I will do the Datalist from there):

If the Chart statement has a IKeyword.TYPE facet that is IKeyword.XY or IKeyword.SCATTER,

Then the IKeyword.VALUE facet value should be :
a point, or a list of points, or a list of list of numbers

Thanks!

Philippe


2014-05-08 19:06 GMT+02:00 Alexis Drogoul <alexis....@gmail.com>:
Well, you should have a look at the IValidator interface and how it can be used (and how it is actually used) in such cases (basically, your data statement description can gather the enclosing description -- chart --, verify its type -- getFacets().get(...) -- and verify the type of the value of its own facet value:
Reply all
Reply to author
Forward
0 new messages