histogram not displaying information

44 views
Skip to first unread message

Chris Harvey

unread,
Jan 9, 2020, 4:42:15 PM1/9/20
to GAMA
Hello everyone,

I have some code for a histogram chart but it's not working and I'm hoping someone can look at my code and tell me why.  Background information - I want a histogram that has 6 bars, each bar represents a different month.  When the simulation data is equal to that month, I want to collect an attribute value and display it in the histogram.  The other month bars should be either at 0 or at the last number given for the attribute in that month.  My code is not providing any bars whatsoever...I'm fairly certain the issue is in the datalist inside the chart.  I'm not sure how to fix this.  Any suggestions would be welcomed.

Thank you,

Chris

code:



global
{

int Total_Abundance_Dec;
int Total_Abundance_Jan;
int Total_Abundance_Feb;
int Total_Abundance_May;
int Total_Abundance_June;
int Total_Abundance_July;



reflex ShrimpNumber
{
    int Sum_shrimp <-0;

    ask PS_shrimp
    {

        loop i over: PS_shrimp
        {

        Sum_shrimp <- Sum_shrimp + self.num_shrimp_per_agent;
       
        }

    }
   
    if (current_date.month = 1)
    {
        Total_Abundance_Jan <- Sum_shrimp;
    }
    else if (current_date.month = 2)
    {
        Total_Abundance_Jan <- Sum_shrimp;
    }
    else if (current_date.month = 12)
    {
        Total_Abundance_Dec <- Sum_shrimp;
    }
    else if (current_date.month = 5)
    {
        Total_Abundance_May <- Sum_shrimp;
    }
    else if (current_date.month = 6)
    {
        Total_Abundance_June <- Sum_shrimp;
    }
    else if (Total_Abundance_July = 7)
    {
        Total_Abundance_July <- Sum_shrimp;
    }
    else
    {
        Sum_shrimp <-0;
    }



    list<int>ShrimpCount <- [Total_Abundance_Dec, Total_Abundance_Jan, Total_Abundance_Feb, Total_Abundance_May, Total_Abundance_June, Total_Abundance_July];

    map<string, list<int>>Shrimp_Abundance <-["Dec"::ShrimpCount[0], "Jan"::ShrimpCount[1], "Feb"::ShrimpCount[2], "May"::ShrimpCount[3], "June"::ShrimpCount[4], "July"::ShrimpCount[5]];




}


experiment Summer type:gui benchmark: false
{

    output{
       

        display PS_Histogram
        {
            chart "Pink Shrimp Abundance" type:histogram
            {
                datalist "Pink Shrimp Abundance" value: Shrimp_Abundance color: #blue;
            }


        }

          }





}
































































}







Srirama Bhamidipati

unread,
Jan 9, 2020, 4:59:27 PM1/9/20
to GAMA
Almost bed time :P

Quick thot, you have double count? "ask species" already asks "each" agent of the asked species... so if you have a loop on the same species again... its double looping. 
Secondly, if you wish to use the inner loop (you shouldnt) , then you are not using the iterator i inside your loop. 

Srirama

Chris Harvey

unread,
Jan 9, 2020, 5:29:10 PM1/9/20
to GAMA
I'll modify it and see if it fixes my issue.  Sleep well.  Its several more hours before bedtime here.

Chris

--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/Ar3wqNXuITc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/17a0fa32-123d-4012-b668-ff63f056fcb2%40googlegroups.com.

Chris Harvey

unread,
Jan 9, 2020, 5:35:36 PM1/9/20
to GAMA
I removed the inner loop over the PS_shrimp and it didn't have any effect.  I still think the issue is in the datalist statement...but I'm guessing - I'm not sure.

On Thu, Jan 9, 2020 at 3:59 PM Srirama Bhamidipati <b.sr...@gmail.com> wrote:

Srirama Bhamidipati

unread,
Jan 10, 2020, 3:36:51 AM1/10/20
to GAMA
hi

Your code is way too complex than it need be, see if you can simplify. Here a simple example


/***
* Name: calendar
* Author: Srirama Bhamidipati
* Description: 
* Tags: Tag1, Tag2, TagN
***/
model calendar

global {
/** Insert the global definitions, variables and actions here */
list<string> myMonths <- ["Jan", "Feb", "Mar"];

init {
loop i over: myMonths {
create calendar_months number: 1 {
monthName <- i;
monthValue <- 10;
}

}

}
reflex stop_simulation  when:cycle = 91{
ask world{
do pause;
}
}

reflex give_value_to_months when: cycle < 90 {
int monthID <- int(cycle / 30);
calendar_months[monthID].monthValue <- calendar_months[monthID].monthValue + rnd(10) - rnd(5);
}

}

species calendar_months {
string monthName;
int monthValue;
}

experiment calendar type: gui {
/** Insert here the definition of the input and output of the model */
float minimum_cycle_duration <- 0.1;
output {
display "charts" {
chart "monthly value" y_range: [0, 200] type: histogram {
datalist myMonths value: list(calendar_months) collect each.monthValue color: [#red, #green, #blue];
To unsubscribe from this group and all its topics, send an email to gama-platform+unsubscribe@googlegroups.com.

Chris Harvey

unread,
Jan 10, 2020, 7:43:28 AM1/10/20
to GAMA
You made a new species...I didn't consider that.  When I get home from work tonight I will try it out...It looks like it's going to work.  I'll get back to you.

Chris

To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/Ar3wqNXuITc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/7caee6b9-ebc3-43d3-ae2b-35157ea74f75%40googlegroups.com.

Chris Harvey

unread,
Jan 10, 2020, 10:22:21 PM1/10/20
to GAMA
your code is behaving exactly how I want to do it.  I don't have my data working in it yet, but this is indeed the behavior that I'm after.  Thank you Srirama

Chris

On Fri, Jan 10, 2020 at 2:36 AM Srirama Bhamidipati <b.sr...@gmail.com> wrote:
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/Ar3wqNXuITc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/7caee6b9-ebc3-43d3-ae2b-35157ea74f75%40googlegroups.com.

Chris Harvey

unread,
Jan 11, 2020, 10:22:23 AM1/11/20
to GAMA
Hi Srirama,

I got it fixed and the histogram is behaving perfectly now.  I have one other issue that I'm having trouble with.  The color of the bars.  I applied the color facet and the chart is ignoring what I put in and is applying different colors.  I would like to have all the bars the same color.  Any ideas?

Chris

On Fri, Jan 10, 2020 at 2:36 AM Srirama Bhamidipati <b.sr...@gmail.com> wrote:
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/Ar3wqNXuITc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/7caee6b9-ebc3-43d3-ae2b-35157ea74f75%40googlegroups.com.

Srirama Bhamidipati

unread,
Jan 11, 2020, 11:26:03 AM1/11/20
to gama-p...@googlegroups.com
glad it works! 
Color Seems a bug. I have no workaround for now.

If no bug, you should use (for a single color)

datalist myMonths value: list(calendar_months) collect each.monthValue color: list_with(length(myMonths),#black );


I do not have time to report the bug, may be you can report it. It a bug with color facet in datalist statement of chart.
To unsubscribe from this group and all its topics, send an email to gama-platform+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/Ar3wqNXuITc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platform+unsubscribe@googlegroups.com.

Chris Harvey

unread,
Jan 11, 2020, 12:02:34 PM1/11/20
to GAMA
I will report it.  Thank you for your help.  I'm building a movie of my simulation - if you'd like I'll send it to you so you can see what I've done.  

On Sat, Jan 11, 2020 at 10:26 AM Srirama Bhamidipati <b.sr...@gmail.com> wrote:
glad it works! 
Color Seems a bug. I have no workaround for now.

If no bug, you should use
datalist myMonths value: list(calendar_months) collect each.monthValue color: list_with(length(myMonths),#black );


I do not have time to report the bug, may be you can report it. It a bug with color in datalist statement.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/Ar3wqNXuITc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/Ar3wqNXuITc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/3e909904-4645-4a88-b3f5-083e5051e816%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages