Bar chart with date variable along x-axis

I am trying to create a very simple bar chart with a daily date variable along the x-axis. The value on the y-axis is either 0 or 1, so a simple indicator for each day that is shown along the x-axis. The desired result would look a bit like a barcode actually.

How can I achieve this kind of graph? In plotTS, I struggled with the lack of a daily frequency option. Using plotBar, I managed the basic appearance of the graph, but couldn't get daily labels along the x-axis to work.

Any help would be appreciated. Thanks!

6 Answers


In GAUSS 19, plotTS can draw daily data and there is also a new function, plotTSHF which can draw high frequency and irregularly spaced data.

How many data points do you have? What is the date range? Is the data from every day in the range?


Thank you very much but unfortunately, I only have GAUSS 18 and that was only just approved by my university a few weeks ago, so I have to manage without GAUSS 19 for now. Is there any alternative I can use right now?

I have data points for 15 years (weekdays only), but it isn't completely regular because of bank holidays.


If your university made a purchase of GAUSS version 18 recently, it is possible that they are also entitled to the new version as well. I would check on that because it will be much, much simpler to do this with the updated time series plotting tools in GAUSS 19.

However, we may be able to come up with something that will work in GAUSS 18.

  1. What does your date vector look like?
  2. How many data points will be on the plot?
  3. What type of formatting do you want for the X-axis labels?


Ok, thanks. Actually, I described the data incorrectly earlier. The indicator is for 2-day windows, so every second day is included.

  1. This is a 954*1 vector of string in "YYYY" generated with dttostr.
  2. It is a 954*1 vector of 0s and 1s.
  3. Given that the data goes from 5th Feb 2009 to 31st May 2016, I obviously only want a few labels, hence the yearly date format.

However, when I run plotBar with the data and "YYYY" labels, no labels appear. I also tried modifying plotXaxisshow but that didn't help.


I think the problem you are having with the X-tick labels on the bar char it is that bar charts are designed to have a tick label for each bar, or 1 for each group of bars. You may be able to get it to work by making the majority of the X-tick labels to be an empty string "" and then placing the year at only a few locations.

However, I came up with a method using plotXY which I think can be made to work. The main steps are:

  1. Create the y data as a series of : 0, 1, ., (where . is a missing value).
  2. Create the x data as a series of 3 of each date in a row, i.e. { 2009, 2009, 2009, 2010, 2010, 2010 }.

I have the code set up so that it creates an initial plot and then adds more vertical bars. The main thing you will have to do from here is to come up with the x coordinates for the daily data. We are happy to assist with this. However, I think it would be best to make a new question which specifically asks about taking your daily data and converting it to a decimal year, i.e. 2012.0125, etc.


// Get x,y pairs for 2009, 2010, ... 2017
first_year = 2009;
n_years = 9;
{ x, y } = getVerticalBars(first_year, n_years);

struct plotControl myPlot;
first_tick_label = 2010;
myPlot = barCodeSettings(first_tick_label);

// Draw vertical bars
plotXY(myPlot, x, y);

// Get x,y pairs for 2009 Q2, 2010 Q2, ... 2012 Q2
first_year = 2009.25;
n_years = 4;
{ x, y } = getVerticalBars(first_year, n_years);

// Add the new vertical bars
plotAddXY(x, y);

proc (2) = getVerticalBars(first_year, n_years);
    local x, y;

    // Make n_yearsx3 vector where each row
    // is { 0 1 . }, so plotTS will draw a vertical bar
    y = reshape(0~1~error(0), n_years, 3);

    // Turn 'y' into a column vector
    // { 0, 1, ., 0, 1, ., etc };
    y = vecr(y);

    // Create a sequence of 'X' values
    // for each 'y', like this { 1, 1, 1, 2, 2, 2, 3, 3, 3, etc };
    x = seqa(first_year, 1, n_years);
    x = x~x~x;
    x = vecr(x);

    retp(x, y);

proc (1) = barCodeSettings(first_tick_label);

    // Declare plotControl struct and fill
    // with default settings
    struct plotControl myPlot;
    myPlot = plotGetDefaults("xy");

    // Get 'set2' color palette
    local clrs;
    clrs = getColorPalette("set2");

    // Set only 1 line color, so that all
    // lines added will be the same color
    clrs = clrs[2];
    plotSetLineColor(&myPlot, clrs);

    plotSetXRange(&myPlot, 2008, 2018);



Awesome, thank you very much!! I will give that a try immediately.

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy